Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (WinAPI, Konsole) » Kurze Frage zur Gui Programmierung

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: > 1 <
000
11.12.2006, 15:59 Uhr
~Devillllll
Gast


Hi
ich bedanke mich schon im Vorraus für jede Hilfe die ich bekomme!
Also ich habe vor ein einem Tag mit der Gui Programmierung angefangen aber aus i.einem Grund ist im Folgenden Code ein Fehler obwohl ich ihn 1 zu 1 aus einem Tutorial kopiert habe. Könnte mir jemand erklären was an dieser Funkrion Falsch ist.



C++:

       case WM_PAINT:
       {
         PAINTSTRUCT ps;
         HDC         hDC;
         const char  szText[] = "Hello world.";
         hDC = BeginPaint(hWnd, &ps);
         {        
            TextOut(hDC, 50, 50, szText, sizeof(szText) - 1);
         }
         EndPaint(hWnd, &ps);    
         return 0;
      }


 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
001
11.12.2006, 16:31 Uhr
J-jayz-Z
Perl Crack ala Carte
(Operator)


Ich kann die Klammern um TextOut herum nicht wirklich nachvollziehen, aber ob das ein Fehler ist, weiß ich gerade nicht. Ansonsten wäre eine Fehlermeldung hilfreich.

Und mit Ansi hat das mal gaaaaar nichts zu tun ->
--
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="66756e2d736f66742e6465"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
002
11.12.2006, 17:37 Uhr
~Devillllll
Gast


Also die Fehlermeldungen lauten:

- In function `LRESULT WindowProcedure(HWND__*, UINT, WPARAM, LPARAM)':
- `hWnd' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
- CDev-Cpp\Makefile.win [Build Error] [kkk.o] Error 1

Mh also an der Klammer liegt es nicht, das habe ich schon getestet!
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
003
11.12.2006, 18:42 Uhr
FloSoft
Medialer Over-Flow
(Administrator)


hWnd muss natürlich auf das Fenster zeigen das die Nachricht bekommen hat. Wenn also dein erster Parameter der WindowsProc(edure) "hWnd" heißt, sollte es funktionieren. Ansonsten musste das halt so nennen wie dein erster Parameter.
--
class God : public ChuckNorris { };
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
004
12.12.2006, 18:31 Uhr
~Devillllll
Gast


Also ich habe alle Parameter richtig eingestellt oder nicht?


C++:

#define STRICT
#include <windows.h>

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

char szClassName[ ] = "WindowsApp";

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

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    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 */
    
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    
    if (!RegisterClassEx (&wincl))
        return 0;

    
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Rechner",       /* 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 */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    
    ShowWindow (hwnd, 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);
    }
    return messages.wParam;
}



LRESULT CALLBACK WindowProcedure (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    switch (message)                  /* handle the messages */
    {
       case WM_PAINT:
       {
         PAINTSTRUCT ps;
         HDC         hDC;
         const char  szText[] = "loolloolloollool";
         hDC = BeginPaint(hwnd, &ps);
         TextOut(hDC, 50, 50, szText, sizeof(szText) - 1);
         EndPaint(hWnd, &ps);
         return 0;
       }      
       case WM_DESTROY:
           PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
           break;
        default:                      /* for messages that we don't deal with */
           return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}


 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
005
12.12.2006, 18:55 Uhr
FloSoft
Medialer Over-Flow
(Administrator)



C++:
hDC = BeginPaint(hwnd, &ps); // "hwnd" != "hWnd" !!!


--
class God : public ChuckNorris { };
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
006
12.12.2006, 19:29 Uhr
~Devillllll
Gast


Ah Sorry hatte die beiden Buchstaben übersehen!
Ok trozalledem sind noch immer Fehlermedung vorhanden:

- [Linker error] undefined reference to `TextOutA@20'
- ld returned 1 exit status
- CDev-Cpp\Makefile.win [Build Error] [Gui.exe] Error 1
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
007
14.12.2006, 10:54 Uhr
Th



Hast du die gdi32.lib eingebunden?
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
008
14.12.2006, 16:34 Uhr
xXx
Devil


hmm und normal solltest du auch lstrlen bzw. strlen nutzen...
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: > 1 <     [ C / C++ (WinAPI, Konsole) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: