I'm using TrackPopupMenuEx inside a UI CWinThread,
CMonitor is derived from CWinThread
monitor_ = (CMonitor *)AfxBeginThread(RUNTIME_CLASS(CMonitor));
CMonitor::InitInstance containes
m_pMainWnd = new CWnd();
m_pMainWnd->CreateEx(WS_EX_TOOLWINDOW | WS_EX_CONTROLPARENT | WS_EX_WINDOWEDGE | WS_EX_TOPMOST, AfxRegisterWndClass(CS_DBLCLKS),
NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_VISIBLE, 50, 50, 50, 50, NULL, NULL);
Then later I do
SetForegroundWindow(AfxGetMainWnd()->m_hWnd);
auto popup_menu_flags = TPM_RETURNCMD | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON | TPM_VERTICAL;
auto menu_item = TrackPopupMenuEx(menu, popup_menu_flags, point.x, point.y, AfxGetMainWnd()->m_hWnd, NULL);
DestroyMenu(menu);
The PopupMenu display correctly and I can use the mouse to select a menu item. However the arrow keys do not work.
I have used Spy++ and m_pMainWnd get messages for WM_KEYUP, VK_DOWN but nothing happens. WM_KEYDOWN is not seen.
What am I missing?
Related
To avoid a duplicate control to CreateWindowEx(0,MONTHCAL_CLASS,...), it is expected to have DateTimePick_Class control showing DropDown Calendar defaultly.
HWND hwndDP = CreateWindowEx(
0,
DATETIMEPICK_CLASS,
TEXT("DateTime"),
WS_BORDER | WS_CHILD | WS_VISIBLE | DTS_SHOWNONE,
50, 20,200,25,
hWnd,
(HMENU)ID_DATETIME_PICKer,
hInst,
NULL);
But it seems that one has to know the control of dropdown arrow button say "ARROW_BTN", like this
SendMessage(hwndDP,WM_NOTIFY,(int)ARROW_BTN,(NMHDR)DTN_DROPDOWN);
or
SendMessage(hwndDP,DTN_DROPDOWN,0,0);
what is the command to retrieve the control ID or some other tricks behind?
So , I have a textbox(in win32) that I made.
TextBox = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT", "Hello you name is: ",
WS_BORDER | WS_CHILD | WS_VISIBLE ,
140,50,500, 250,
hwnd, NULL, NULL , NULL);
My question is: How can I get to add multiple text in the "textbox"
My program is mostly made out of questions that i ask and the user responds to it.
Question two: How can I make this "dialog" between the user and the computer.
Last, but not least, I've made these buttons:
Submit = CreateWindow("BUTTON", "Submit", WS_VISIBLE | WS_CHILD | WS_BORDER,
450,320,80,20,
hwnd, (HMENU) 1, NULL, NULL);
SubmitQuestion = CreateWindow("BUTTON", "Inregistreaza raspuns", WS_VISIBLE | WS_CHILD | WS_BORDER,
310,350,150,26,
hwnd, (HMENU) 2, NULL, NULL);
Next = CreateWindow("BUTTON", "Next", WS_VISIBLE | WS_CHILD | WS_BORDER,
250,320, 80, 20,
hwnd, (HMENU) 2, NULL , NULL);
Submit works, but when I press next nothing happens. How can the user by clicking "NEXT" can go to the next question and also when he presses submit his answer to be registered?
And also , how by SendMessage , classes are included (calling functions ) ---> I have a method of "questions" (8) and i don't know how to call it in order to work with the textbox and win32 syntax.
Your editbox needs to have a unique ID (passed in the hMenu parameter). If you intend for the editbox to display more than one line of text it also needs to have ES_MULTILINE style.
Each of your buttons also needs to have a unique ID.
Your other questions are not clear.
In WM_CREATE message of my main window procedure I create a listview with the next code:
hMyList = CreateWindowA( WC_LISTVIEW,TEXT(""), WS_CHILD | WS_VISIBLE |
LVS_LIST | LVS_TYPEMASK , XPOS(450), YPOS(20), NWIDTH(200),
NHEIGHT(200),hWnd,(HMENU) 9876, hInst, NULL);
Then I insert code to add a column to that listview:
LVCOLUMN column;
column.mask = LVCF_TEXT;
column.pszText = "Name";
SendMessage(hMyList, LVM_INSERTCOLUMN, NULL, (LPARAM)&column );
//returns 0; so everything is fine
But column doesn't appear in the listview.
What can be the source of the problem?
Columns are visible only in report/details view of the listview. To switch it in that mode you should post LVM_SETVIEW message to it, or use LVS_REPORT style instead of LVS_LIST in the CreateWindowA.
I am new in vc++ and i need a Password field in my application. I created edit textbox using below code but don't know how to create password field and button control.
CreateWindow(L"EDIT", L"hello", WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
ES_AUTOHSCROLL | ES_WANTRETURN, 350, 500, 130, 20, hwnd, NULL, NULL, NULL);
Any help would be grateful. thanks
Try ES_PASSWORD :
Displays an asterisk (*) for each
character typed into the edit control.
This style is valid only for
single-line edit controls.
Windows XP: If the edit control is
from user32.dll, the default password
character is an asterisk. However, if
the edit control is from comctl32.dll
version 6, the default character is a
black circle.
To change the characters that is
displayed, or set or clear this style,
use the EM_SETPASSWORDCHAR message.
Note Comctl32.dll version 6 is not
redistributable but it is included in
Windows XP or later. To use
Comctl32.dll version 6, specify it in
a manifest. For more information on
manifests, see Enabling Visual Styles.
Source : Edit Control Styles
Edit
You mean creating a button ? Via Using Buttons :
HWND hwndButton = CreateWindow(
L"BUTTON", // Predefined class; Unicode assumed.
L"OK", // Button text.
WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
0, // x position.
0, // y position.
50, // Button width.
50, // Button height.
hwnd_parentwindow,
NULL, // No menu.
(HINSTANCE)GetWindowLong(hwnd_parentwindow, GWL_HINSTANCE),
NULL);
You can select the edit box and right click and choose its properties. In that there is an option called password. Just check it.
Also this link will help you.
http://msdn.microsoft.com/en-us/library/d3223ht2.aspx
Or if you want you can directly add
ES_PASSWORD
also along with rest.
I have created a skin in VC++ through the win32 API. Now I want to add controls to the skins. How can this be achieved?
By using following code, its a button with bit map image.
hButton = CreateWindow ("BUTTON", "", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP | WS_TABSTOP |WS_EX_OVERLAPPEDWINDOW | BS_BITMAP| BS_FLAT|EDGE_SUNKEN,
175, 135, B_width1, B_height1, hWnd, (HMENU)IDB_BUTTON_WOPEN,
((LPCREATESTRUCT) lParam)->hInstance, NULL);
/* Set the button image */
SendMessage(hButton[7], BM_SETIMAGE, IMAGE_BITMAP,
(LPARAM)LoadBitmap(hInst, MAKEINTRESOURCE(IMG_BITMAP7)));