How can I add controls to Skins in win32 API - winapi

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)));

Related

Is it possible to set DateTimePicker to dropdown the monthCalendar by default?

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?

TrackPopupMenuEx not seeing keys inside CWinThread

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?

Win32 Api - a more dialog-based program

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.

how to create password field and button in vc++

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.

Placing a window in WIN CE

How do we specify the placement position of a window using MFC in Win CE? It does not support the WINDOWPLACEMENT class that is available in Windows.
The CreateWindowsEx seems to have a x and y coordinates to position the window.
Update:
Also if you look at the code of the resource file rc you will see:
MYDIALOG_DIALOG DIALOG 0, 0, 182, 97
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW | 0x80000000L
CAPTION "mycaption"
FONT 8, "MS Shell Dlg"
BEGIN
CONTROL 132,IDC_STATIC,"Static",SS_BITMAP,7,7,20,18
LTEXT "blah blah",IDC_STATIC,32,11,133,12
CONTROL "some control",IDC_DEVICE_BTN,"Button",BS_AUTORADIOBUTTON,58,33,64,10
CONTROL "control",IDC_HOST_BTN,"Button",BS_AUTORADIOBUTTON,58,49,57,10
PUSHBUTTON "control",IDC_BUTTON1,64,73,47,17
END
Notice the MYDIALOG_DIALOG DIALOG 0, 0, 182, 97 first 0, 0 - that is the window positioning.

Resources