aswang
1.0
|
00001 /* 00002 Copyright 2003 Joseph Alvis 00003 00004 This file is part of Aswang. 00005 00006 Aswang is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU Lesser General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 Aswang is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public License 00017 along with Aswang. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include "PopupMenu.h" 00021 00022 using namespace aswang; 00023 00024 bool PopupMenu::Create() { 00025 if((mHandle=CreatePopupMenu())!=NULL) 00026 return true; 00027 return false; 00028 } 00029 00030 bool PopupMenu::Append(const AswangStr &name,unsigned int id) { 00031 if(mHandle) 00032 return (AppendMenu(mHandle,MF_STRING,id,name.c_str())==1); 00033 return false; 00034 } 00035 00036 bool PopupMenu::SetCheck(unsigned int id,bool checked) { 00037 if(mHandle) 00038 return (CheckMenuItem(mHandle,id,(checked?MF_CHECKED:MF_UNCHECKED))!=-1); 00039 return false; 00040 } 00041 00042 unsigned int PopupMenu::Track(HWND owner) { 00043 if(mHandle) { 00044 POINT p={0}; 00045 GetCursorPos(&p); 00046 return TrackPopupMenu(mHandle,TPM_RETURNCMD,p.x,p.y,0,owner,NULL); 00047 } 00048 return 0; 00049 }