Wieso, hab ich die Dos-Shell im Hintergrund ?



  • hi,

    ich programmier mir gerade ne app und hab dabei folgendes Prob:

    mein code sieht so aus:

    #if !defined SimpleWndH
    #define      SimpleWndH
    
    #define UNICODE         //make active when compiling on WinNT/2000/XP (W-fns)
    #define WIN32_LEAN_AND_MEAN    //optional: no mfc
    #include <windows.h>           //include all the basics
    
    //=========================================================================================
    //declare the Window procedure where all messages will be handled
    LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam);
    
    //=========================================================================================
    //start the application; all win32 applications require a WinMain function
    //that the windows operating system looks for as an entry point to that application
    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
    {
    HWND    hwnd;    //the wnd handle
    MSG     Msg;     //a simple structure for storing message information
    HICON   hIcon;   //window icon
    HCURSOR hCursor; //window cursor
    
    //declare and initialise wnd registration information variables
    
    TCHAR chClassName[]=TEXT("SIMPLEWND");
    WNDCLASSEX wcx;    //this structure is used for storing information about the wnd 'class'
    //use 'LoadImage' to load wnd class icon and cursor as it supercedes the obsolete functions
    //'LoadIcon' and 'LoadCursor', although these functions will still work. Because the icon and
    //cursor are loaded from system resources ie they are shared, it is not necessary to free the
    //image resources with either 'DestroyIcon' or 'DestroyCursor'.
    hIcon=(HICON)LoadImage(0,IDI_APPLICATION,IMAGE_ICON,0,0,LR_SHARED);
    hCursor=(HCURSOR)LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED);
    
    wcx.cbSize           = sizeof(WNDCLASSEX);              //byte size of WNDCLASSEX struct
    wcx.style            = CS_HREDRAW|CS_VREDRAW;           //ensure wnd is always redrawn
    wcx.lpfnWndProc      = (WNDPROC)WndProc;                //pointer to the Window Procedure
    wcx.cbClsExtra       = 0;                               //Extra bytes for 'class' wnds
    wcx.cbWndExtra       = 0;                               //Extra bytes for this wnd
    wcx.hInstance        = hInstance;                       //Application instance
    wcx.hIcon            = hIcon;                           //Application icon
    wcx.hCursor          = hCursor;                         //Cursor for wnd
    wcx.hbrBackground    = (HBRUSH)(COLOR_BTNFACE+1);       //Background wnd colour
    wcx.lpszMenuName     = NULL;                            //Name of wnd menu
    wcx.lpszClassName    = chClassName;                     //Name of this wnd 'class'
    wcx.hIconSm          = NULL;                            //Icon in top-left corner of wnd
    
    //Register the wnd class with the Windows system
    if (!RegisterClassEx(&wcx))
        {
        //Registration has failed so inform the user
        MessageBox( NULL,
                    TEXT("Failed to register wnd class"),
                    TEXT("ERROR"),
                    MB_OK|MB_ICONERROR);
        return FALSE;
        }
    //create wnd of the 'class' just registered
    hwnd=CreateWindowEx(0,                                  //more or 'extended' styles
                        chClassName,                        //the 'class' of window to create
                        TEXT("Simple Window"),              //the window title
                        WS_OVERLAPPEDWINDOW,                //window style: how it looks
                        GetSystemMetrics(SM_CXSCREEN)/4,    //window position: left
                        GetSystemMetrics(SM_CYSCREEN)/4,    //window position: top
                        GetSystemMetrics(SM_CXSCREEN)/3,    //window width
                        GetSystemMetrics(SM_CYSCREEN)/3,    //window height
                        NULL,                               //parent window handle
                        NULL,                               //handle to this windows's menu
                        hInstance,                          //application instance
                        NULL);                              //user defined information
    if (!hwnd)
        {
        //wnd creation has failed so inform the user 
        MessageBox( NULL,
                    TEXT("Failed to create wnd"),
                    TEXT("ERROR"),
                    MB_OK|MB_ICONERROR);
        return FALSE;
        }
    //Display the wnd
    ShowWindow(hwnd,nCmdShow);
    UpdateWindow(hwnd);
    //start message loop
    while (GetMessage(&Msg,NULL,0,0)>0)
        {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
        }
    return Msg.wParam;
    }
    //=========================================================================================
    LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)
    {
    switch (Message)
        {
        case WM_DESTROY:
            PostQuitMessage(0);    //signal end of application
            return 0;
        default:
            return DefWindowProc(hwnd,Message,wParam,lParam);  //let system deal with msg
        }
    }
    //=========================================================================================
    #endif
    

    Wenn ich das starte hab ich ne DOS-BOX im Hintergrund, kann ich das nich abstellen oder die irgendwie verstecken ?

    MfG,

    OHPen



  • Hat nichts mit C++ zu tun. 🙂

    Ab nach "ähhhhhh, ich lass Hume entscheiden". 🙂



  • Ja, wie jetzt !?

    Krieg ich also keine Antwort ?



  • Nicht in diesem Forum. Welchen Compiler nutzt du?



  • DEV C++ von Bloodshed, hat das was mit dem Compiler zu tun ?



  • Hab ich mir schon fast gedacht! Du erstellt ein neues Projekt und mußt da "Windows Application" wählen und nicht "Console Applicaton". 🙂



  • Und das mit

    #if !defined SimpleWndH
    #define SimpleWndH

    .........

    #endif

    gehört in Header-Dateien und nicht in .cpp Dateien.



  • Danke ihr hab mir sehr geholfen,

    bis dann,

    Gruss OHPen


Anmelden zum Antworten