Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

WHY MY WINDOW DOESNT SHOW ?

Posted on 2003-03-11
3
Medium Priority
?
339 Views
Last Modified: 2011-08-18
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 ?
0
Comment
Question by:olivboy
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
Nosfedra earned 120 total points
ID: 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).


0
 

Author Comment

by:olivboy
ID: 8110346
Thanks a lot Nosfedra ! That stupid MAKEINTRESOURCE solved the problem.
0
 
LVL 3

Expert Comment

by:Nosfedra
ID: 8110383
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Simple Linear Regression

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question