Sign in to follow this  

no matching function

This topic is 4109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im' trying to make a window with Direct X but it keeps giving this error: Line 46 Window.cpp argument of type `LRESULT (Window::)(HWND__*, UINT, WPARAM, LPARAM)' does not match `LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM)' window.cpp
//include Window header 
#include <Window.h> 

// set function so it can be used it in WNDCLASSEX
LRESULT WINAPI MainMessageProcedure(HWND handle,UINT message,WPARAM wParam,LPARAM lParam);

// set constructor  
Window::Window() { 
// initializeer alle variablen 
 window_handle = NULL; 
 paused = FALSE; 
 active = TRUE; 
 alive = TRUE; 
 windowed = FALSE; 
 window_height = 600; 
 window_width = 800;                  
 strcpy(window_class,"Project_Mage"); 
 strcpy(window_title,"Project_Mage Version 0.1"); 
} 

// set destructor 
Window::~Window(){ 
 if (window_handle) 
  DestroyWindow(window_handle); 
  UnregisterClass(window_class, GetModuleHandle(NULL));                     
} 

// set create window function 
BOOL Window::Create_window(int width , int height , BOOL in_window){ 

//create structure for window properties 
WNDCLASSEX wc; 
// set size  
 wc.cbSize = sizeof(WNDCLASSEX);        
// set window style
 wc.style = CS_CLASSDC;                  
// set message handler
 wc.lpfnWndProc = MainMessageProcedure;  
// set extra bytes for structure
 wc.cbClsExtra = 0;                      
// set extra bytes for window instance
 wc.cbWndExtra = 0;                      
// set unique HINSTANCE
 wc.hInstance = GetModuleHandle(NULL);  
// set cursor
 wc.hCursor = LoadCursor(NULL, IDC_ARROW);   
// set background
 wc.hbrBackground = NULL;                
// set windows Icon
 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
// set Icon Sm
 wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// set class
wc.lpszClassName = window_class;              
// set menu 
wc.lpszMenuName = NULL;  

// register structuur 
RegisterClassEx(&wc); 

//if not in window mode go to fullscreen 
if (!windowed){ 
 width = GetSystemMetrics(SM_CXFULLSCREEN);
 height = GetSystemMetrics(SM_CYFULLSCREEN); 
} 

// create window 
window_handle = CreateWindow(window_class,window_title,((windowed)?WS_OVERLAPPEDWINDOW:WS_POPUPWINDOW),
                0,0,width,height,NULL,NULL,wc.hInstance,NULL);   

// check for valid hanlde
 if(window_handle == NULL) 
   return FALSE; 

// windows shows window 
ShowWindow(window_handle,SW_SHOW); 
// windows updates window 
UpdateWindow(window_handle); 
// windows shows the cursor      
ShowCursor(TRUE);  

return TRUE; 
// end create_window function             
} 

// set the execute function 
void Window::Run(){ 
// create window 
 if(!Create_window(800,600,TRUE)) 
  return; 
// call initialize function 
 if(!FirstInitialize()) 
  return; 
// go into loop 
 Loop();  
// call clean function 
 FinalCleanup(); 
}       
   
// set the loop 
void Window::Loop(){ 
// store recieved messages
 MSG message_store; 
 ZeroMemory(&message_store, sizeof(MSG));  
// create loop to continue window display 
 while (message_store.message != WM_QUIT && alive != FALSE){ 
// use peak message to see if there's a message 
 if (PeekMessage(&message_store,NULL,0,0,PM_REMOVE)){ 
// translate the message 
  TranslateMessage(&message_store); 
// send to message handler 
  DispatchMessage(&message_store);} 
 else {
// if we are in else there's no message and we can render  
  if(active) { 
   if(!paused){ 
// call prerender and render 
    if(!PreRender()) 
     break; 
    if(!Render())                  
     break; 
// close the complete loop 
}}}}}               

// message handler
LRESULT WINAPI Window::MainMessageProcedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam){ 
// message contains all messages sent through
 switch(message) {

// when not clicking our window  
  case WM_ACTIVATE:
    switch(wParam){
// aplication is activate
     case WA_ACTIVE:         
// set active to TRUE to start rendering again
      active = TRUE;
       break;
// when clicking in the window     
     case WA_CLICKACTIVE:   
// set active to TRUE to start rendering again    
      active = TRUE;
       break;
// aplication is no longer selected
     case WA_INACTIVE:      
// set active to false
      active = FALSE;
       break;
// end switch wParam
  }return 0;
//end case WM_Activate  
  break; 

// window is being destroyed 
  case WM_DESTROY: 
   PostQuitMessage(0);
  return 0;
// end case WM_DESTROY  
  break;

// change size window (maximize,minimize)
  case WM_SIZE:
   switch(wParam){
// window is minimized    
    case SIZE_MINIMIZED:   
// de-activate     
     active = FALSE;
    break;
// window is restored    
    case SIZE_RESTORED:     
// set active to TRUE to start rendering again     
     active = TRUE;
    break;
// window is maximized		
    case SIZE_MAXIMIZED:    
// window is active     
     active = TRUE;
    break;		
// end switch wParam        
  }return 0;
// end case WM_SIZE		
  break;

// Key is pressed
  case WM_KEYDOWN:
   switch(wParam){
// escape key is pressed    
    case VK_ESCAPE:             
     PostQuitMessage(0);
    break;
// pause key is pressed    
    case VK_PAUSE: 
// change value pause to unpause or pause
     paused = !paused;
    break;
// end switch   
   }return 0;
// end case WM_KEYDOWN		
   break;

// send all other messages to the default message handler	
  default: return DefWindowProc(handle,message, wParam, lParam);
// end switvh (message)  
 }
// end  message handler
}   

// end                               


window.h
 
// include windows header 
#include <windows.h> 
// create class Window 
class Window
{ 
 public : 
// create constructor 
   Window(); 
// create distructor 
   virtual~Window();  
// create run function 
   void Run(); 
// create message handler method 
   virtual LRESULT WINAPI MainMessageProcedure(HWND handle,UINT message,WPARAM wParam,LPARAM lParam); 

protected : 
// this function creates a window 
   BOOL Create_window(int width , int height , BOOL in_window); 
// create loop function 
   void Loop();  
// create initialize function
   virtual BOOL FirstInitialize(){return TRUE;} 
// clean up function used in the end 
   virtual BOOL FinalCleanup(){return TRUE;} 
// function before rendering 
   virtual BOOL PreRender(){return TRUE;} 
// function after rendering 
   virtual BOOL Render(){return TRUE;} 
// handle for window 
   HWND window_handle; 
// pause or not paused 
   BOOL paused; 
// active or not 
   BOOL active; 
// alive or not 
   BOOL alive; 
// fullscreen or window 
   BOOL windowed; 
// window width 
   UINT window_width; 
// window height          
   UINT window_height;  
// window class 
   char window_class[100]; 
// window title 
   char window_title[100]; 
}; 

// end   


Share this post


Link to post
Share on other sites
You can't pass a non-static member function as the WndProc like that I'm afraid. It needs to be a static member function or a non-member function, since otherwise the function doesn't have an address as such, without an instance of the object.

There are some tutorials in GameDev's resources section that discuss ways to address this if memory serves.

Share this post


Link to post
Share on other sites

This topic is 4109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this