Thanks a lot Nosfedra ! That stupid MAKEINTRESOURCE solved the problem.
Main Topics
Browse All TopicsI've made an C API application that shows a dialog with a textfield and 2 buttons.I use the code below but it doesnt work...it just compile correctly.
#include <windows.h>
#include "resource.h"
#define BUFFER_SIZE 256
BOOL CALLBACK EditDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
char szText[BUFFER_SIZE];
switch(Message)
{
case WM_INITDIALOG:
SendDlgItemMessage(hwnd, IDC_EDITDLG_TEXT, EM_SETLIMITTEXT, (WPARAM)BUFFER_SIZE - 1, (LPARAM)0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_EDITDLG_SETTEXT:
GetDlgItemText(hwnd, IDC_EDITDLG_TEXT, szText, BUFFER_SIZE);
SetWindowText(hwnd, szText);
return TRUE;
case IDCANCEL:
EndDialog(hwnd, IDCANCEL);
return TRUE;
}
break;
}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
int ret;
ret = DialogBox(hInstance, "EDITDLG", NULL, EditDlgProc);
}
I used the resource editor in VC++ 6 for building the dialog. I forgot to mention that i dont want a "main window" using WNDCLASSEX or stuff like that...Just the dialog.
Anybody knows what happens ?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I'm glad it worked out. I am wishing however to post soon a question about that macro, as I am a bit puzzled about its role. Actually, it converts the ID of the resource to a LPSTR or LPTSTR string, doing some funny conversions there.
#define MAKEINTRESOURCEA(i) (LPSTR) ((DWORD) ((WORD) (i)))
or Unicode:
#define MAKEINTRESOURCEW(i) (LPWSTR) ((DWORD) ((WORD) (i)))
And since the function documentation says there that it should get the template __name__, I wonder what is that template name afterall...
You might want to follow that thread...
Regards...
Business Accounts
Answer for Membership
by: NosfedraPosted on 2003-03-11 at 03:45:41ID: 8110302
Try instead of putting there the string "EDITDLG", using the macro MAKEINTERESOURCE(EDITDLG), assuming that this is the identifier of the dialog.
It should work.
MAKEINTRESOURCE takes into account the Unicode representation of the resource name and using the macro is always a good practice. In general,this macro should be used any time a resource is accessed in the program (for bitmaps, icons, menus etc).