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.
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?
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?
I am working on one project in win32 API. Here, I want the user to type a text in a search bar and the first corresponding words should pop-up. When the user is done with the typing or selects the word, clicking on the 'Process' button should display another message box. I want the search bar should look as this:
I want each word to display a different message box when the user clicks on the 'Process' button. Implying that, the application must be able to store data such that it can be retrieved. So far, I have this code which can store data and be retrieved.
HWND hWndComboBox = CreateWindow (TEXT("COMBOBOX"), TEXT (""),
CBS_DROPDOWN| CBS_HASSTRINGS | WS_VSCROLL| WS_VISIBLE |WS_CHILD ,
100, 20, 200, 70,
hwnd ,(HMENU) NULL, NULL, NULL);
CreateWindow (TEXT("BUTTON"), TEXT ("Process "),
WS_VISIBLE | WS_CHILD ,
200, 100, 70, 20,
hwnd,(HMENU) NULL, NULL, NULL);
SendMessage (
hWndComboBox ,
(UINT) CB_ADDSTRING,
(WPARAM) 0, (LPARAM) TEXT ("Apple"));
SendMessage (
hWndComboBox ,
(UINT) CB_ADDSTRING,
(WPARAM) 0, (LPARAM) TEXT ("Apple juice"));
SendMessage (hWndComboBox , CB_GETCURSEL , (WPARAM) 0, (LPARAM) 0);
Here, what I cannot do is that there is no default word like "Search Fruits" which clears when the user begins to type. Moreover, when the user selects 'Apple' and clicks on the 'Process' button, no dialog box is displayed. I do not know how to call the message box to respond depending on the user inputs. And also, the small search icon on the right of the search box.
Please what should I do? I am using win32 API Code:Blocks. Any further question for clarification is welcome. Any link or answer is most welcome. Thank you all.
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)));