Eigene GUI elemente



  • Funktioniert irgendwie nicht.
    Der Code:

    #pragma once
    #include <windows.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    class mGUI
    {
    public:
    	mGUI(void);
    	~mGUI(void);
    	HWND m_hWnd;
    	bool Create(DWORD dwExStyle,LPCTSTR lpLabel, DWORD Style,
    				int x, int y, int nWidth, int nHeight, HWND hWndParent,HMENU hMenu,HINSTANCE hInstance, LPVOID lpParam );
    	WNDCLASSEX winc;
    	bool Register(UINT style,
        WNDPROC lpfnWndProc,
        int cbClsExtra,
        int cbWndExtra,
        HINSTANCE hInstance,
        HICON hIcon,
        HCURSOR hCursor,
        HBRUSH hbrBackground,
        LPCTSTR lpszMenuName,
        LPCTSTR lpszClassName,
        HICON hIconSm);
    	static LRESULT CALLBACK WinProc(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int cmndshow);
    };
    
    #include ".\mgui.h"
    
    mGUI::mGUI(void)
    {
    }
    
    mGUI::~mGUI(void)
    {
    }
    
    bool mGUI::Create(DWORD dwExStyle,LPCTSTR lpLabel, DWORD Style,
    				int x, int y, int nWidth, int nHeight, HWND hWndParent,HMENU hMenu,HINSTANCE hInstance, LPVOID lpParam)
    {
    	CreateWindowEx(dwExStyle,winc.lpszClassName,lpLabel,Style,x,y,nWidth,nHeight,hWndParent,hMenu,hInstance,lpParam);
    
    	return true;
    }
    
    bool mGUI::Register(
        UINT style,
        WNDPROC lpfnWndProc,
        int cbClsExtra,
        int cbWndExtra,
        HINSTANCE hInstance,
        HICON hIcon,
        HCURSOR hCursor,
        HBRUSH hbrBackground,
        LPCTSTR lpszMenuName,
        LPCTSTR lpszClassName,
        HICON hIconSm
    )
    {
    	winc.cbSize=sizeof(WNDCLASSEX);
    	winc.style	= style;
    	winc.cbClsExtra	= cbClsExtra;
    	winc.cbWndExtra	= cbWndExtra;
    	winc.lpfnWndProc	= WinProc;
    	winc.hInstance	= hInstance;
    	winc.hIcon	= hIcon;
    	winc.hCursor	= hCursor;
    	winc.hbrBackground	=hbrBackground;
    	winc.lpszMenuName	= lpszMenuName;
    	winc.lpszClassName	= lpszClassName;
    	winc.hIconSm		= hIconSm;
    	return true;
    }
    
    LRESULT CALLBACK mGUI::WinProc(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int cmndshow)
    {
    	return LRESULT();
    }
    


  • Der Fehler?



  • Steht doch oben. Die Funktion WinProc wird nicht von der WNDCLASSEX angenommen.



  • INTEGER schrieb:

    Steht doch oben. Die Funktion WinProc wird nicht von der WNDCLASSEX angenommen.

    Na kein Wunder, ist ja auch nicht vom selben Funktionstyp. Du weist der WndProc von WNDCLASSEX eine Funktion zu die bis zum Namen eine WndProc ist und eine Parameterliste wie die WinMain hat...

    Schau dir das nochmal genau in der MSDN an 🙄

    MfG SideWinder



  • Stimmt, hab garnicht gemerkt, dass die Parameter total falsch sind.



  • LRESULT CALLBACK mGUI::WinProc(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int cmndshow)
    {
    return LRESULT();
    }

    WinProc(HINSTANCE hinstance, HINSTANCE hprevinstance, LPSTR lpcmdline, int cmndshow) 
    { 
        return LRESULT(); 
    }
    

    ohne Klassenname.



  • @Der_Toni
    wenn du schon was berichtigst, dann bitte richtig.
    Deine Codevorgabe ist der gleiche Scheiß in Lila getupft, halt ohne Klassenbezug, und ohne Rückgabe Bezeichnung der Funktion.



  • halt ohne Klassenbezug

    Jip, so sollte es sein.

    und ohne Rückgabe Bezeichnung der Funktion.

    Hatte ich leider vergessen.



  • Hm, ich glaube ich hatte das mit "friend" verwechselt. 😮



  • Die Rede ist immer noch von den Parametern der WNDPROC.


Anmelden zum Antworten