altes gegen neues Fenster tauschen



  • Hi

    So, ich habe momentan keine Idee, wie ich folgendes Problem anpacken soll.

    ich habe zu Anfang ein kleine Fenster in dem man sich anmelden soll
    ähnlich wie icq oder so

    wenn man dann auf starten klickt, soll sich das Fenster schliessen und ein neues größeres Hauptfenster öffnen (mit eigener CALLBACK Funktion). Gleichzeitig sollen die Anmeldungsdaten an das neue Fenster übergeben werden.

    Jetzt weiß ich nicht, wie ich das neue Hauptfenster mit eigener Callback Funkion öffnen soll. Am besten wäre es, wenn ich das auch in einer anderen cpp datei programmieren kann (also über header dann aufrufen).

    habe es so versucht

    /* Register the window class, and if it fails quit the program */
        if (!RegisterClassEx (&wincl))
            return 0;
    
        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Code::Blocks Template Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               300,                 /* The programs width */
               500,                 /* 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 */
               );
    
        /* Make the window visible on the screen */
        ShowWindow (hwnd, nFunsterStil);
        UpdateWindow (hwnd);
    
        /* The class is registered, let's create the program*/
        hwnd2 = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Code::Blocks Template Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               10,       /* Windows decides the position */
               10,       /* where the window ends up on the screen */
               200,                 /* The programs width */
               400,                 /* and height in pixels */
               hwnd,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               NULL,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    
        /* Make the window visible on the screen */
        ShowWindow (hwnd2, nFunsterStil);
        UpdateWindow (hwnd2);
    
        /* 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;
    }
    

    Das Problem ist allerdings, dass beide Fenster die selbe Callback Funktion haben (selbe windowclass) und somit auch die selben Button usw.

    Danke an euch



  • Du willst eine eigene Callback-Funktion für zwei verschiedene Fenster?
    Wieso verwendest du dann für beide die selbe Klasse?

    helpme schrieb:

    Hi

    /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
            -->szClassName,         /* Classname */
               "Code::Blocks Template Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               CW_USEDEFAULT,       /* Windows decides the position */
               CW_USEDEFAULT,       /* where the window ends up on the screen */
               300,                 /* The programs width */
               500,                 /* 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 */
               );
    
        /* Make the window visible on the screen */
        ShowWindow (hwnd, nFunsterStil);
        UpdateWindow (hwnd);
    
        /* The class is registered, let's create the program*/
        hwnd2 = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
            -->szClassName,         /* Classname */
               "Code::Blocks Template Windows App",       /* Title Text */
               WS_OVERLAPPEDWINDOW, /* default window */
               10,       /* Windows decides the position */
               10,       /* where the window ends up on the screen */
               200,                 /* The programs width */
               400,                 /* and height in pixels */
               hwnd,        /* The window is a child-window to desktop */
               NULL,                /* No menu */
               NULL,       /* Program Instance handler */
               NULL                 /* No Window Creation data */
               );
    }
    

    Du hast doch das Problem selber erkannt, wieso änderst du die nicht einfach und nimmst zwei verschiedene?
    Und falls es unbedingt sein muss, kannst du dem Fenster ja auch noch eine ID geben, dann kannst du zwischen den beiden unterscheiden...
    Und falls du es ganz umständlich machen willst, geb dem Fenster eine ID, lass die Klasse gleich und subclass sie dann bei WM_CREATE...


Log in to reply