#include <windows.h> 
#include "resource.h" 

const char g_szClassName[] = "myWindowClass";
return; DialogBox(hInstance, MAKEINTRESOURCE(IDD_SIMPLECONTROL), NULL, SimpleProc);}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
BOOL CALLBACK SimpleProc(HWND hWndDlg, UINT Message, WPARAM wParam, 
LPARAM lParam){switch(Message){
case WM_INITDIALOG:
       return TRUE;
case WM_COMMAND:switch ( LOWORD (wParam) ) {
     case ID_HELLO:MessageBox(NULL,"Hey", "Hallo!", MB_OK);
break; 
case ID_FILE_EXIT:EndDialog(hWndDlg, 0)
break;
case WM_CLOSE:EndDialog(hWndDlg, 0); 
break; 
default: 
         return FALSE;}
         return TRUE;}

what am i doing wrong??

mvmalderen commented: Rrrrrrrubbbbbiiisssh! -2

Recommended Answers

All 10 Replies

I'm not surprised. All you posted is a bunch of meaningless lines of code. Try writing a real program with functions etc.

In other words, you don't know anything about C++ and just randomly pasted the contents of a tutorial into your text editor. What a surprise that it doesn't compile. :icon_rolleyes:

commented: Hehe, you hit the nail right on the head. :) +8

In other words, you don't know anything about C++ and just randomly pasted the contents of a tutorial into your text editor. What a surprise that it doesn't compile. :icon_rolleyes:

This is C section, i know primitive functions but can never write on my own... my whole programs are combination of various code snippets, this one is dialog box example, which im struggling to find for a year. Now that i found it, it fails to compile because "SimpleProc" is not defined. and that is the only error im getting.

>This is C section
Pardon. You don't know C, and randomly pasted shit into a text editor. The fact remains that you clearly don't have the prerequisite knowledge to write this program.

>my whole programs are combination of various code snippets
I strongly recommend you learn more about the basic language before jumping into Win32. That opens up a whole new can of worms, and if you're not pretty comfortable with straight C, it'll be a nightmare.

i just need an example of what am i doing wrong in this one, i did not ask you what books to read or where to start...

...

I can't even laugh at this, it's too sad. I wish you the best of luck, because that's all you have left.

I have recopied the code, re arranged it and it still won't work...

#include <windows.h> 
#include "resource.h" 

const char g_szClassName[] = "myWindowClass";
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
BOOL CALLBACK SimpleProc(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam);
}
DialogBox(hInstance, MAKEINTRESOURCE(IDD_SIMPLECONTROL), NULL, SimpleProc);LPARAM lParam){switch(Message)
     case WM_INITDIALOG:
     return TRUE;
     case WM_COMMAND:
     switch ( LOWORD (wParam) ) {
     break;
     case ID_HELLO:
MessageBox(NULL,"Hey", "Hallo!", MB_OK);
     break; 
     case ID_FILE_EXIT:
          EndDialog(hWndDlg, 0)
     break;
     case WM_CLOSE:
          EndDialog(hWndDlg, 0); 
     break; 
default: 
return TRUE;}

Anyone who is willing to help, please reply.

Mate, just look at your code and try to make some logic out of it. Here, I'll give you a hand.

On line 7 you have a closing brace ( } ), but up to line 7, there are no opening braces. Something must be wrong...

On the next line, line 8 , the structure of your parentheses looks like this: (( ))) . You are opening two, but you are closing three.

At the end of the same line you begin a switch/case statement. You use a Message variable which has not been declared before. You're also not using braces, but they are mandatory.

These errors can be found on each line of your code. So to sum my point up, it's way too buggy to be used. Even you solve the problem you've previously mentioned, the code won't work. So you either start learning C, or you'll be struggling with this problem for another 2 to 10 years.

Ditch that tutorial you are reading and try this one. Its been around for many years and has been used by hundreds of people. You need a basic knowledge of C language -- if you don't have it then you might be in trouble. The turotial comes with complete source code that you can download, compile, and run.

commented: :) +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.