someone please tell me what I can do to make this compile

also what would be better is explaining what i could do to diagnose how to make this compile when i get errors like this. I'm trying to superclass a window and im getting these errors

122 C:\Dev-Cpp\pocketrocket.cpp expected constructor, destructor, or type conversion before '(' token
122 C:\Dev-Cpp\pocketrocket.cpp expected `,' or `;' before '(' token

here is the code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <windows.h>
#include <string>
#include  <stdio.h>
#define ID_1 1000
#define ID_2 1001
#define blah 1003
    HWND mainwin;  
    HWND hwnd2;
char ID_ONE;
/*  Declare Windows procedure  */
LRESULT CALLBACK Proc2 (HWND, UINT, WPARAM, LPARAM);
WNDCLASSEX wincl2;
/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil)

{
             /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX winclz;        /* Data structure for the windowclass */
    
    /* The Window structure */
    winclz.hInstance = hThisInstance;
    winclz.lpszClassName = szClassName;
    winclz.lpfnWndProc = Proc2;      /* This function is called by windows */

    winclz.style = CS_DBLCLKS;                 /* Catch double-clicks */
    winclz.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    winclz.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    winclz.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    winclz.hCursor = LoadCursor (NULL, IDC_ARROW);
    winclz.lpszMenuName = NULL;                 /* No menu */
    winclz.cbClsExtra = 0;                      /* No extra bytes after the window class */
    winclz.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    winclz.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&winclz))
        return 0;

HMENU hmenu = CreateMenu();
	InsertMenu(hmenu, 1, MF_BYPOSITION | MF_STRING, ID_ONE, NULL);
	
HMENU hSubMenu2 = CreatePopupMenu();
      AppendMenu(hSubMenu2, MF_STRING, ID_1, "connect");
      AppendMenu(hSubMenu2, MF_STRING, ID_2, "quit");
      InsertMenu(hmenu, 0, MF_POPUP|MF_BYPOSITION, (UINT_PTR)hSubMenu2, "Actions");
      
      
      
    /* The class is registered, let's create the program*/
    mainwin = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Pocket Rocket client",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           hmenu,                /* some menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

 hwnd2 = CreateWindowEx (0, "EDIT", "", WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, 100, 24, mainwin,	NULL, GetModuleHandle(NULL), NULL);
    /* Make the window visible on the screen */
    ShowWindow (mainwin, nFunsterStil);

                                  

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
}

int WINAPI WinMain (HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpszArgument,
                    int nFunsterStil);
/*  This function is called by the Windows function DispatchMessage()  */


LRESULT CALLBACK Proc2(HWND mainwin, UINT message, WPARAM wParam, LPARAM lParam )
{
switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;

    } 
     switch (wParam)                  /* handle the messages */
    {
                  case ID_2 :
                PostQuitMessage(0);
                  case ID_1 :
                   ShowWindow (hwnd2, SW_SHOW);     
                   EnableWindow(mainwin, false); 
                                      default:                      /* for messages that we don't deal with */
            return DefWindowProc (mainwin, message, wParam, lParam);
    }  

        return 0;
}
GetClassInfoEx (NULL, winclz, wincl2);
LRESULT CALLBACK Proc1(HWND hwnd2, UINT message, WPARAM wParam, LPARAM lParam)
{
        switch (message)
        {
               case WM_DESTROY:
                    PostQuitMessage (0);
                    break;
                           default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd2, message, wParam, lParam);
                    }
                    return 0;
                    }


of course its not finished, this will be my first program that I've made that's actually useful not something like iostream input word output sentence with word or hello world etc, so anything else you see that could help me improve would be greatly appreciated.
What is line 122? If it is meant to be a function prototype, it is missing the return value. If not, then explain what is supposed to be.
@Ikaron: I know the Windows API contains a function called like that. It is NOT what I am asking. I am asking the person who wrote this code about the intended purpose of line #122.
@webJose: Sorry, you weren't being very clear when you stated "If it is meant to be a function prototype, it is missing the return value." Which, if that's the case, it's not only missing a return value but also its argument types. This ambiguity in your statement is why I even bothered to point out the function's existance as a Windows function in the first place, just incase you weren't aware that it was a Windows API call.
Last edited on
I see. I guess it is my bad then.

What I am trying to do here is to understand the purpose of the line in order to provide an appropriate fix. I could say "remove the line", but I don't really know if that will yield the expected result or not. The intention of that line must be known before appropriate action can be taken to correct it.

Let's see if the OP comes back to clarify the intention.
Oh, no, I totally understand your need to understand what the line is there for. I just misinterpreted your post. :)
I'm trying to superclass a window and I couldn't find any good c++ examples online, the point of line 122 is to implement the first step in accomplishing that. According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms633569%28v=vs.85%29.aspx

To superclass a window class, an application first calls the GetClassInfo function to retrieve information about the base class. GetClassInfo fills a WNDCLASS structure with the values from the WNDCLASS structure of the base class. Next, the application copies its own instance handle into the hInstance member of the WNDCLASS structure and copies the name of the superclass into the lpszClassName member. If the base class has a menu, the application must provide a new menu with the same menu identifiers and copy the menu name into the lpszMenuName member. If the superclass procedure processes the WM_COMMAND message and does not pass it to the window procedure of the base class, the menu need not have corresponding identifiers. GetClassInfo does not return the lpszMenuName, lpszClassName, or hInstance member of the WNDCLASS structure.

So I tried doing that but i can't even get it to compile after adding getclassinfo, can't figure out what im doing wrong.
Last edited on
help plz >_<
Topic archived. No new replies allowed.