WHY MY WINDOW DOESNT SHOW ?

I'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 ?
olivboyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NosfedraCommented:
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).


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
olivboyAuthor Commented:
Thanks a lot Nosfedra ! That stupid MAKEINTRESOURCE solved the problem.
0
NosfedraCommented:
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...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.