?
Solved

WHY MY WINDOW DOESNT SHOW ?

Posted on 2003-03-11
3
Medium Priority
?
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

800 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