<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Fehler beim kompilieren (C, WinAPI, GCC)]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte ein kleines Programm in C schreiben. Es soll ein Fenster geben mit ein paar Buttons, die beim Betätigen eine Grafik im Fenster auswechseln.<br />
Ich wollte anfangen mit Fenster und Buttons.<br />
Ich bin neu in WinAPI und wollte mir ein kleines Beispiel, das ich im Netz gefunden habe, anschauen.<br />
Hier der Code:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;commctrl.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

#include &quot;main.h&quot;
#include &quot;resource.h&quot;

/* Declare WindowsProcedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the classname into a global variable */
char szClassName[] = &quot;Windows Example&quot;;
char szMessageName[] = &quot;Info&quot;;

char *string = new char[30];

HINSTANCE hInstance;

const UINT IDTimer1 = 1;
UINT nTimerDelay = 2000;
bool timerFlag = true;

#define IDC_RADIOBUTTON1 10

BOOL GetFileName(HWND hwnd, LPSTR pszFileName, BOOL bSave)
{
OPENFILENAME ofn;

ZeroMemory(&amp;ofn, sizeof(ofn));
pszFileName[0] = 0;

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = &quot;Text Files (*.txt)*.txtAll Files (*.*)*.*&quot;;
ofn.lpstrFile = pszFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = &quot;txt&quot;;

if(bSave)
{
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT;
if(!GetSaveFileName(&amp;ofn))
return FALSE;
}
else
{
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(!GetOpenFileName(&amp;ofn))
return FALSE;
}
return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFensterStil)

{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application is saved */
WNDCLASSEX wincl; /* Datastructure for the windowclass */
HMENU menu; /* Handle of the menu */

/* The Window structure */
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Ctach double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);

/* Use default icon and mousepointer */
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
// Hintergrundfarbe des Main-Fensters
wincl.hbrBackground = (HBRUSH) GetStockObject(10);

/* Register the window class, if fail quit the program */
if(!RegisterClassEx(&amp;wincl)) return 0;

/* The class is registered, lets create the program*/
hwnd = CreateWindowEx(
0, /* Extended possibilites for variation */
szClassName, /* Classname */
&quot;Windows Example&quot;, /* Title Text */
WS_OVERLAPPEDWINDOW, /* defaultwindow */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window end up on the screen */
600, /* The programs width */
400, /* and height in pixels */
HWND_DESKTOP, /* The window is a childwindow to desktop */
NULL, /* No menu */
hInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow(hwnd, nFensterStil);
UpdateWindow(hwnd);
menu = LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU));
SetMenu(hwnd, menu);

/* Run the nessageloop. It will run until GetMessage( ) returns 0 */
while(GetMessage(&amp;messages, NULL, 0, 0))
{
/* Send message to WindowProcedure */
DispatchMessage(&amp;messages);
}
return messages.wParam;
}

/* This function is called by the Windowsfunction DispatchMessage( ) */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int i=0;
// Höhe und Breite des Buttons
static int bx=100, by=30; 
static HWND hwndButtonStart = 0;
static HWND hwndButtonEnde = 0;
static HWND RadioButton1 = 0;
static HWND RadioButton2 = 0;
static HWND Test = 0;
static HWND Test1 = 0;

HDC hdc;/* A device context used for drawing */
PAINTSTRUCT ps;/* Also used during window drawing */
RECT rc;/* A rectangle used during drawing */

switch (message) /* handle the messages */
{
case WM_COMMAND:

//Button Kommandos
if ((HWND) lParam == hwndButtonStart)
{
//Ausführen Button Start

MessageBox( hwnd, (LPSTR) &quot;Keine Funktion Implementiert!&quot;,
(LPSTR) szMessageName,
MB_ICONINFORMATION | MB_OK );

return 0;
}
if((HWND) lParam == hwndButtonEnde)
{
//Ausführen Button Ende
DestroyWindow (hwnd);
}
if((HWND) lParam == RadioButton1) {

return 0;
} 
//Ende Button Kommandos
switch( wParam )
{
case IDM_FILENEW:

case IDM_FILEOPEN:
char szFileName[MAX_PATH];
GetFileName( hwnd, szFileName, FALSE);
break;

case IDM_EDITUNDO:
case IDM_EDITCUT:
case IDM_EDITCOPY:
case IDM_EDITPASTE:
case IDM_EDITDELETE:
MessageBox( hwnd, (LPSTR) &quot;Keine Funktion Implementiert!&quot;,
(LPSTR) szClassName,
MB_ICONINFORMATION | MB_OK );
break;

case IDM_HELPCONTENTS:
WinHelp( hwnd, (LPSTR) &quot;HELPFILE.HLP&quot;,
HELP_CONTENTS, 0L );
return 0;

case IDM_HELPSEARCH:
WinHelp( hwnd, (LPSTR) &quot;HELPFILE.HLP&quot;,
HELP_PARTIALKEY, 0L );
return 0;

case IDM_HELPHELP:
WinHelp( hwnd, (LPSTR) &quot;HELPFILE.HLP&quot;,
HELP_HELPONHELP, 0L );
return 0;

case IDM_FILEEXIT:
SendMessage( hwnd, WM_CLOSE, 0, 0L );
return 0;

case IDM_HELPABOUT:
MessageBox (NULL, &quot;About...&quot; , &quot;Windows example version 0.01&quot;, 1);
return 0;

} //Ende WM_Command
break;

case WM_CLOSE:
DestroyWindow( hwnd );
return 0;

case WM_DESTROY:
PostQuitMessage (0);
return 0;

case WM_CREATE:
//Timer initialisieren
SetTimer(hwnd, IDTimer1,nTimerDelay, NULL);
// Buttons werden erstellt
hwndButtonStart = CreateWindow (&quot;button&quot;,&quot;Start&quot;,WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,100, 250, bx, by,
hwnd,(HMENU) 1,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

hwndButtonEnde = CreateWindow (&quot;button&quot;,&quot;Ende&quot;,WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,400, 250, bx, by,
hwnd,(HMENU) 2,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

/*
RadioButton1 = CreateWindow (&quot;button&quot;,&quot;Radio1&quot;,WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON,100, 130, 70, 20,
hwnd,(HMENU) IDC_RADIOBUTTON1,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

RadioButton2 = CreateWindow (&quot;button&quot;,&quot;Radio2&quot;,WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON,200, 130, 70, 18,
hwnd,(HMENU) 4,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);
*/

Test = CreateWindow (&quot;button&quot;,&quot;&quot;,WS_CHILD | WS_VISIBLE | BS_GROUPBOX,50, 50, 500, 250,
hwnd,(HMENU) 5,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

Test1 = CreateWindow (&quot;edit&quot;,&quot;Feld&quot;, WS_CHILD | WS_VISIBLE | BS_TEXT,100, 130, 70, 20,
hwnd,(HMENU) 5,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

break;

case WM_PAINT:
hdc = BeginPaint (hwnd, &amp;ps);
GetClientRect (hwnd, &amp;rc);
rc.bottom = 50;
DrawText(hdc, &quot;Die neue Version von WorkClock!&quot;, -1,&amp;rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);

EndPaint (hwnd, &amp;ps);
break;

return 0; //Ende WM_Paint

case WM_TIMER:
if(timerFlag==true){
i++;

timerFlag = false;
int id = MessageBox( hwnd, (LPSTR) &quot;Timer!&quot;,
(LPSTR) szClassName,
MB_ICONINFORMATION | MB_OKCANCEL);

// Button Cancel liefert 2 zurück
// Button OK liefert 1 zurück 
if(id == 1) {
timerFlag = true;
}

SendMessage( hwnd, WM_PAINT, 0, 0L );
} 

break;
//Für nicht beachtete Nachrichten
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
</code></pre>
<p>Ich weiß nicht was der Code genau macht, aber in der Beschreibung stand, dass das ein Fenster mit zwei Butons ist.</p>
<p>Das Problem ist: wenn ich mit &quot;gcc win.c&quot; kompiliere kommt die Fehlermeldung:<br />
&quot;C:/DOKUME<sub>1/rolly/LOKALE</sub>1/Temp/ccuCbaa.o(.text+0x81):win.c: undefined reference to `GetStockObject@4'&quot;</p>
<p>Was könnte das sein? Fehler im Code? Falsch kompiliert?<br />
Ich habe nur eine &quot;win.c&quot;, brauche ich auch eine &quot;resource.h&quot; und eine &quot;main.h&quot;?<br />
Benutze MinGW auf WinXP.</p>
<p>Dank und Grüße,<br />
rolly</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/157397/fehler-beim-kompilieren-c-winapi-gcc</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 16:20:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/157397.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Aug 2006 11:57:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehler beim kompilieren (C, WinAPI, GCC) on Fri, 25 Aug 2006 11:57:22 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte ein kleines Programm in C schreiben. Es soll ein Fenster geben mit ein paar Buttons, die beim Betätigen eine Grafik im Fenster auswechseln.<br />
Ich wollte anfangen mit Fenster und Buttons.<br />
Ich bin neu in WinAPI und wollte mir ein kleines Beispiel, das ich im Netz gefunden habe, anschauen.<br />
Hier der Code:</p>
<pre><code>#include &lt;windows.h&gt;
#include &lt;commctrl.h&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

#include &quot;main.h&quot;
#include &quot;resource.h&quot;

/* Declare WindowsProcedure */
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
/* Make the classname into a global variable */
char szClassName[] = &quot;Windows Example&quot;;
char szMessageName[] = &quot;Info&quot;;

char *string = new char[30];

HINSTANCE hInstance;

const UINT IDTimer1 = 1;
UINT nTimerDelay = 2000;
bool timerFlag = true;

#define IDC_RADIOBUTTON1 10

BOOL GetFileName(HWND hwnd, LPSTR pszFileName, BOOL bSave)
{
OPENFILENAME ofn;

ZeroMemory(&amp;ofn, sizeof(ofn));
pszFileName[0] = 0;

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = &quot;Text Files (*.txt)*.txtAll Files (*.*)*.*&quot;;
ofn.lpstrFile = pszFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrDefExt = &quot;txt&quot;;

if(bSave)
{
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT;
if(!GetSaveFileName(&amp;ofn))
return FALSE;
}
else
{
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
if(!GetOpenFileName(&amp;ofn))
return FALSE;
}
return TRUE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFensterStil)

{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application is saved */
WNDCLASSEX wincl; /* Datastructure for the windowclass */
HMENU menu; /* Handle of the menu */

/* The Window structure */
wincl.hInstance = hInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Ctach double-clicks */
wincl.cbSize = sizeof(WNDCLASSEX);

/* Use default icon and mousepointer */
wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
// Hintergrundfarbe des Main-Fensters
wincl.hbrBackground = (HBRUSH) GetStockObject(10);

/* Register the window class, if fail quit the program */
if(!RegisterClassEx(&amp;wincl)) return 0;

/* The class is registered, lets create the program*/
hwnd = CreateWindowEx(
0, /* Extended possibilites for variation */
szClassName, /* Classname */
&quot;Windows Example&quot;, /* Title Text */
WS_OVERLAPPEDWINDOW, /* defaultwindow */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window end up on the screen */
600, /* The programs width */
400, /* and height in pixels */
HWND_DESKTOP, /* The window is a childwindow to desktop */
NULL, /* No menu */
hInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Make the window visible on the screen */
ShowWindow(hwnd, nFensterStil);
UpdateWindow(hwnd);
menu = LoadMenu(hInstance, MAKEINTRESOURCE(ID_MENU));
SetMenu(hwnd, menu);

/* Run the nessageloop. It will run until GetMessage( ) returns 0 */
while(GetMessage(&amp;messages, NULL, 0, 0))
{
/* Send message to WindowProcedure */
DispatchMessage(&amp;messages);
}
return messages.wParam;
}

/* This function is called by the Windowsfunction DispatchMessage( ) */
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int i=0;
// Höhe und Breite des Buttons
static int bx=100, by=30; 
static HWND hwndButtonStart = 0;
static HWND hwndButtonEnde = 0;
static HWND RadioButton1 = 0;
static HWND RadioButton2 = 0;
static HWND Test = 0;
static HWND Test1 = 0;

HDC hdc;/* A device context used for drawing */
PAINTSTRUCT ps;/* Also used during window drawing */
RECT rc;/* A rectangle used during drawing */

switch (message) /* handle the messages */
{
case WM_COMMAND:

//Button Kommandos
if ((HWND) lParam == hwndButtonStart)
{
//Ausführen Button Start

MessageBox( hwnd, (LPSTR) &quot;Keine Funktion Implementiert!&quot;,
(LPSTR) szMessageName,
MB_ICONINFORMATION | MB_OK );

return 0;
}
if((HWND) lParam == hwndButtonEnde)
{
//Ausführen Button Ende
DestroyWindow (hwnd);
}
if((HWND) lParam == RadioButton1) {

return 0;
} 
//Ende Button Kommandos
switch( wParam )
{
case IDM_FILENEW:

case IDM_FILEOPEN:
char szFileName[MAX_PATH];
GetFileName( hwnd, szFileName, FALSE);
break;

case IDM_EDITUNDO:
case IDM_EDITCUT:
case IDM_EDITCOPY:
case IDM_EDITPASTE:
case IDM_EDITDELETE:
MessageBox( hwnd, (LPSTR) &quot;Keine Funktion Implementiert!&quot;,
(LPSTR) szClassName,
MB_ICONINFORMATION | MB_OK );
break;

case IDM_HELPCONTENTS:
WinHelp( hwnd, (LPSTR) &quot;HELPFILE.HLP&quot;,
HELP_CONTENTS, 0L );
return 0;

case IDM_HELPSEARCH:
WinHelp( hwnd, (LPSTR) &quot;HELPFILE.HLP&quot;,
HELP_PARTIALKEY, 0L );
return 0;

case IDM_HELPHELP:
WinHelp( hwnd, (LPSTR) &quot;HELPFILE.HLP&quot;,
HELP_HELPONHELP, 0L );
return 0;

case IDM_FILEEXIT:
SendMessage( hwnd, WM_CLOSE, 0, 0L );
return 0;

case IDM_HELPABOUT:
MessageBox (NULL, &quot;About...&quot; , &quot;Windows example version 0.01&quot;, 1);
return 0;

} //Ende WM_Command
break;

case WM_CLOSE:
DestroyWindow( hwnd );
return 0;

case WM_DESTROY:
PostQuitMessage (0);
return 0;

case WM_CREATE:
//Timer initialisieren
SetTimer(hwnd, IDTimer1,nTimerDelay, NULL);
// Buttons werden erstellt
hwndButtonStart = CreateWindow (&quot;button&quot;,&quot;Start&quot;,WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,100, 250, bx, by,
hwnd,(HMENU) 1,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

hwndButtonEnde = CreateWindow (&quot;button&quot;,&quot;Ende&quot;,WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,400, 250, bx, by,
hwnd,(HMENU) 2,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

/*
RadioButton1 = CreateWindow (&quot;button&quot;,&quot;Radio1&quot;,WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON,100, 130, 70, 20,
hwnd,(HMENU) IDC_RADIOBUTTON1,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

RadioButton2 = CreateWindow (&quot;button&quot;,&quot;Radio2&quot;,WS_CHILD | WS_VISIBLE | BS_RADIOBUTTON,200, 130, 70, 18,
hwnd,(HMENU) 4,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);
*/

Test = CreateWindow (&quot;button&quot;,&quot;&quot;,WS_CHILD | WS_VISIBLE | BS_GROUPBOX,50, 50, 500, 250,
hwnd,(HMENU) 5,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

Test1 = CreateWindow (&quot;edit&quot;,&quot;Feld&quot;, WS_CHILD | WS_VISIBLE | BS_TEXT,100, 130, 70, 20,
hwnd,(HMENU) 5,((LPCREATESTRUCT) lParam)-&gt;hInstance,NULL);

break;

case WM_PAINT:
hdc = BeginPaint (hwnd, &amp;ps);
GetClientRect (hwnd, &amp;rc);
rc.bottom = 50;
DrawText(hdc, &quot;Die neue Version von WorkClock!&quot;, -1,&amp;rc,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);

EndPaint (hwnd, &amp;ps);
break;

return 0; //Ende WM_Paint

case WM_TIMER:
if(timerFlag==true){
i++;

timerFlag = false;
int id = MessageBox( hwnd, (LPSTR) &quot;Timer!&quot;,
(LPSTR) szClassName,
MB_ICONINFORMATION | MB_OKCANCEL);

// Button Cancel liefert 2 zurück
// Button OK liefert 1 zurück 
if(id == 1) {
timerFlag = true;
}

SendMessage( hwnd, WM_PAINT, 0, 0L );
} 

break;
//Für nicht beachtete Nachrichten
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
</code></pre>
<p>Ich weiß nicht was der Code genau macht, aber in der Beschreibung stand, dass das ein Fenster mit zwei Butons ist.</p>
<p>Das Problem ist: wenn ich mit &quot;gcc win.c&quot; kompiliere kommt die Fehlermeldung:<br />
&quot;C:/DOKUME<sub>1/rolly/LOKALE</sub>1/Temp/ccuCbaa.o(.text+0x81):win.c: undefined reference to `GetStockObject@4'&quot;</p>
<p>Was könnte das sein? Fehler im Code? Falsch kompiliert?<br />
Ich habe nur eine &quot;win.c&quot;, brauche ich auch eine &quot;resource.h&quot; und eine &quot;main.h&quot;?<br />
Benutze MinGW auf WinXP.</p>
<p>Dank und Grüße,<br />
rolly</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124356</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124356</guid><dc:creator><![CDATA[rolly]]></dc:creator><pubDate>Fri, 25 Aug 2006 11:57:22 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim kompilieren (C, WinAPI, GCC) on Fri, 25 Aug 2006 12:05:32 GMT]]></title><description><![CDATA[<p>Du musst die GDI32.lib mitlinken...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124366</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124366</guid><dc:creator><![CDATA[~Airdamn]]></dc:creator><pubDate>Fri, 25 Aug 2006 12:05:32 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim kompilieren (C, WinAPI, GCC) on Fri, 25 Aug 2006 12:21:12 GMT]]></title><description><![CDATA[<p>Danke, und wie mache ich das (in GCC)?</p>
<p>Grüße,<br />
*totalerNewbee*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124378</guid><dc:creator><![CDATA[rolly]]></dc:creator><pubDate>Fri, 25 Aug 2006 12:21:12 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim kompilieren (C, WinAPI, GCC) on Fri, 25 Aug 2006 12:24:49 GMT]]></title><description><![CDATA[<p>Oh mann, sorry, hab oben falschen code gepostet.<br />
Hier der richtige:</p>
<pre><code>#include &lt;windows.h&gt;

LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam);

HDC dc;
HWND button1, button2;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, int nCmdShow)

{
WNDCLASS wc;
HWND hWnd;
MSG msg;
wc.style = CS_HREDRAW|CS_VREDRAW|CS_BYTEALIGNCLIENT;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = &quot;ButtonExample&quot;;
RegisterClass(&amp;wc);

hWnd = CreateWindow(wc.lpszClassName,&quot;Using A Button&quot;,
WS_OVERLAPPEDWINDOW,100,100,300,200,
NULL,NULL,hInstance,NULL);

button1 = CreateWindow(&quot;BUTTON&quot;,&quot;Hit Me&quot;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
10,10,120,40,hWnd,NULL,hInstance,NULL);
button2 = CreateWindow(&quot;BUTTON&quot;,&quot;Hit Me, too&quot;,WS_CHILD |WS_VISIBLE| BS_PUSHBUTTON,
90,50,120,40,hWnd,NULL,hInstance,NULL);

ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&amp;msg,NULL,0,0))
{
TranslateMessage(&amp;msg);
DispatchMessage(&amp;msg);
}
return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
switch(uMsg)
{
case WM_COMMAND:
{
if ((HWND)lParam==button1)
MessageBox(hwnd,&quot;Clicked!&quot;,&quot;Ooohhh&quot;,MB_OK);
return 0;
}

case WM_DESTROY:
{
PostQuitMessage(0);
break;
}
default:
{
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
}
return 0;
}
</code></pre>
<p>Grüße,<br />
rolly</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124382</guid><dc:creator><![CDATA[rolly]]></dc:creator><pubDate>Fri, 25 Aug 2006 12:24:49 GMT</pubDate></item><item><title><![CDATA[Reply to Fehler beim kompilieren (C, WinAPI, GCC) on Fri, 25 Aug 2006 12:26:00 GMT]]></title><description><![CDATA[<p>rolly schrieb:</p>
<blockquote>
<p>Danke, und wie mache ich das (in GCC)?</p>
</blockquote>
<p>an die kommandozeile ein</p>
<pre><code>-lgdi32
</code></pre>
<p>mit dranhängen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124384</guid><dc:creator><![CDATA[net 0]]></dc:creator><pubDate>Fri, 25 Aug 2006 12:26:00 GMT</pubDate></item></channel></rss>