Sign in to follow this  

creating error_check window

This topic is 4119 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

I'm trying to create a error window that is called like this : Error_check * check = new Error_check("error found on line 20 !"); but it gives an empty white window. Error_check.h
// Adriaan Larmuseau 
// Sylvarant Studios 
// Project-Mage version 0.1  

//------------------------------------------------------------------------------
// ERROR_CHECK HEADER VERSION 0.1
//------------------------------------------------------------------------------

#include "Windows.h"
class Error_check {

public:
 // create window handle 
HWND error_handle;
// set window properties
void Win_prop();
// update function 
void Window_status();
// constructor
Error_check(char* error_report);
// destructor
~Error_check();
};

 
// Adriaan Larmuseau 
// Sylvarant Studios 
// Project-Mage version 0.1  

//------------------------------------------------------------------------------
// ERROR_CHECK SOURCE CODE VERSION 0.1
//------------------------------------------------------------------------------ 
#include "Error_check.h"

char window_class[40] = "Error_check";

// create message handler method 
LRESULT WINAPI Error_handler(HWND handle,UINT message,WPARAM wparam,LPARAM lparam); 

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

// register structuur 
 RegisterClassEx(&wac); 
} 

Error_check::Error_check(char* error_report){ 
// create window properties 
Win_prop();
// create window 
Error_check::error_handle = CreateWindow("Error_check","Error_check",WS_POPUPWINDOW,
                300,200,200,200,NULL,NULL,GetModuleHandle ( NULL ),NULL);
//error message box 
MessageBox(Error_check::error_handle,error_report, "Project-Mage error!", MB_OK|MB_ICONSTOP);     
// update window status
Window_status(); 
} 

void Error_check::Window_status(){
 // windows shows window 
ShowWindow(Error_check::error_handle,SW_SHOW); 
// windows updates window 
UpdateWindow(Error_check::error_handle); 
// windows shows the cursor      
ShowCursor(TRUE);  
}  


Error_check.cpp
 
// Adriaan Larmuseau 
// Sylvarant Studios 
// Project-Mage version 0.1 

Main.cpp  
//------------------------------------------------------------------------------
// MAIN SOURCE CODE VERSION 0.1
//------------------------------------------------------------------------------


#include "Window_main.h"  
#include "Error_check.h"
#include <iostream>
#include <stdio.h> 

using namespace std;

// make global pointer for Main window message handler
Window_main * pointer_window_main = NULL;   
// make global
Window_main * pointer_error = NULL;

//------------------------------------------------------------------------------
// MAIN FUNCTION
//------------------------------------------------------------------------------
 int WINAPI WinMain(HINSTANCE instance, HINSTANCE instance_02, LPSTR line, int cmd){

//------------------------------------------------------------------------------
// Rendering
//------------------------------------------------------------------------------            
    // create pointer_error 
    pointer_error = new Window_main;
    // create a new Game_main 
    pointer_window_main = new Window_main;  
    // call run methode 
    pointer_window_main->Run(); 
    // delete pointer 
    delete pointer_window_main;    
   
   printf ("\nHit Enter to exit\n");
   while(scanf("enter")) {}	 //Loop until return is hit

    
    return 0;
   
}
 
// pass all messages to the alredy made message handler 
LRESULT WINAPI MainMessageProcedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
{
    return pointer_window_main->MessageProcedure(handle, message, wParam, lParam);
}   

// initailize error handler for Error_check window
LRESULT WINAPI Error_handler(HWND handle,UINT message,WPARAM wParam,LPARAM lParam) 
{ 
   return pointer_error->MessageProcedure(handle, message, wParam, lParam); 
} 

Share this post


Link to post
Share on other sites

This topic is 4119 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