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.
Related
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 writing a win32 application with the following code in Recourse.rc
IDD_DLGFIRST DIALOG 260, 200, 188, 95
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Win32 Programming"
FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK", IDOK, 130, 10, 50, 14
END
When I try to compiler the following code with MinGW, Windres.exe gives me an error on the second line
I figured out what the problem was.
I forgot to #include windows.h for the style macros.
using c++ under visual studio 2010.
I have a dialog creation section
IDD_LOGON DIALOGEX 0, 0, 265, 70
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Log On to Windows"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
EDITTEXT IDC_NAME,61,9,127,14,ES_AUTOSCROLL
EDITTEXT IDC_PASSWORD,61,29,127,14,ES_PASSWORD | ES_AUTOSCROLL
EDITTEXT IDC_DOMAIN,61,49,127,14,ES_AUTOSCROLL
DEFPUSHBUTTON "OK",IDOK,204,8,50,14
PUSHBUTTON "Cancel",IDCANCEL,204,25,50,14
LTEXT "Domain:",IDC_STATIC,21,52,27,8
LTEXT "Password:",IDC_STATIC,21,32,34,8
LTEXT "User Name:",IDC_STATIC,17,12,38,8
PUSHBUTTON "Shutdown",IDC_SHUTDOWN,204,49,50,14
END
I would like to have an image in the background of this dialog.
How would i go about performing this action?
thank you
In your OnInitDialog() use:
this->SetBackgroundImage(IDB_BITMAP1, BACKGR_TOPLEFT, TRUE);
For more info refer : CDialogEx::SetBackgroundImage
There is no way to do this through the dialog template/designer. You will need to handle the WM_ERASEBKGND message in your dialog and paint the background yourself.
Here is some info:
http://www.codeproject.com/Articles/18967/Bitmap-Backgrounds-For-Dialog-Boxes
quick answer... i dropped the image control on the dialog, set the image... then... i went into the code and placed it at the TOP of the stack, and it was painted with no issues. the transparent portion of the other controls was failing, so i grouped them all into an area of the same background color on the image, and walla - all done. thank you
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)));