Autor Beitrag
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Fr 16.11.07 15:59 
Hallo,

ich habe mir soeben ein Tutorial bei www.pronix.de/pronix-1036.html angesehen. Es geht darum, richtige Windows anstatt Konsolenfenstern zu erstellen. Leider klappt das Compilieren nicht (ich nutze GCC aus Cygwin for Microsoft Windows). Hier der Code:

ausblenden volle Höhe Quelltext
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:
#include <windows.h>

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

LPCSTR lpszAppName = "AppName";
LPCSTR lpszTitle   = "Meine erste Applikation";

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     PSTR szCmdLine, int iCmdShow)
{
    HWND       hWnd;
    MSG        msg;
    WNDCLASSEX wc;

    wc.cbSize        =  sizeof(WNDCLASSEX);
    wc.style         =  CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   =  WndProc;
    wc.cbClsExtra    =  0;
    wc.cbWndExtra    =  0;
    wc.hInstance     =  hInstance;
    wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
    wc.hIcon         =  LoadIcon(NULL, IDI_APPLICATION);
    wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.lpszClassName =  lpszAppName;
    wc.lpszMenuName  =  lpszAppName;
    wc.hIconSm       =  LoadIcon(NULL, IDI_APPLICATION);

    if( RegisterClassEx(&wc) == 0)
        return 0;

    hWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
                          lpszAppName,
                          lpszTitle,
                          WS_OVERLAPPEDWINDOW,
                          0,
                          0,
                          CW_USEDEFAULT,
                          CW_USEDEFAULT,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);

    if( hWnd == NULL)
        return 0;

    ShowWindow(hWnd, iCmdShow);
    UpdateWindow(hWnd);

    while (GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
    switch (umsg)
    {
        case WM_DESTROY:
        {
            PostQuitMessage(0);
            return 0;
        }
    }
    return DefWindowProc(hWnd, umsg, wParam, lParam);
}


Natürlich habe ich den Code ersteinmal nur kopiert, ohne ihn zu verändern, um zu sehen, ob es funktioniert, wäre ja schön... Jedenfalls klappt das Compilieren nicht, kann man den Code verändern, so, dass es klappt?
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Fr 16.11.07 16:10 
Mit C habe ich mich vor 15 Jahren zuletzt befasst... Du solltest aber auf jeden Fall mehr Informationen geben:
user profile iconJakob_Ullmann hat folgendes geschrieben:
Jedenfalls klappt das Compilieren nicht, kann man den Code verändern, so, dass es klappt?

Das ist keine ausreichende Fehlermeldung. Was gefällt dem Compiler denn nicht (Meldung, Zeile, sonstige Hinweise)? Ohne solche Erläuterungen kann Dir niemals jemand helfen. Jürgen
Jakob_Ullmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Fr 16.11.07 16:26 
Sry, vor lauter Aufregung vergessen (Screenshot im Anhang). Anscheinend scheint irgendetwas mit dieser einen Funktion nicht zu stimmen.
Einloggen, um Attachments anzusehen!
TGLDX
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 22



BeitragVerfasst: Fr 16.11.07 16:39 
Entweder du linkst zusätlich die GDI32.lib oder lässt GetStockObject raus, also so:

ausblenden Quelltext
1:
 wc.hbrBackground =  (HBRUSH)(WHITE_BRUSH);					
Jakob_Ullmann Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Sa 17.11.07 19:24 
Ah, danke, funktioniert. Jedebfalls wenn ich das GetStockObject weglasse. Aber wie binde ich die GDI32.lib ein? Mit include geht es jedenfalls nicht:
ausblenden C#-Quelltext
1:
#include "GDI32.lib"					

geht nicht, auch nicht wenn ich die " durch < ersetze. Welche Direktive brauche ich?
Greenberet
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 339
Erhaltene Danke: 20

Win 10
C# (VS 2012), C++ (VS 2012/GCC), PAWN(Notepad++), Java(NetBeans)
BeitragVerfasst: Sa 17.11.07 20:03 
#import