Syntax Error from Windres.exe when creating Dialog Template - winapi

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.

Related

Resizing an edit window

I have a simple edit window:
hwndEdit = CreateWindow(
TEXT("EDIT"),
TEXT("EDIT"),
WS_BORDER | WS_CHILD | ES_LEFT,
100,
100,
100,
30,
gHwnd,
0,
hInst,
0);
I have noticed that when I paste there a text which is longer than an edit window width I get notification (EN_CHANGE) which contains only a portion of the text which fits a window width. I would like to resize an edit window (SetWindowPos) when a text is longer than the edit window width. I can create an edit window based on MSFTEDIT_CLASS and use EN_REQUESTRESIZE. Do you know any other solution or that is the only option ?
The text is truncated by your edit control on paste.
To allow more text in that control without changing the size (which is not practical for many reasons), simply add ES_AUTOHSCROLL style to your CreateWindow call.

Implementing a dialog background image

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

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.

How can I add controls to Skins in win32 API

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

Resources