Win32 and functions

All questions regarding Windows programming, post here. API,COM, ActiveX, DirectX, OpenGL, MFC and so on...

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Win32 and functions

Postby brechtjah » Thu Nov 06, 2008 3:56 pm

Hi,
I have started learning Win32 recently and would like to know how I can create functions in Win32 as I did in console C++. I want to execute a function with the click of a button, however, when I try to do this I get an error saying that my function is not declared or a constructor etc. is expected...

My code is:

void Function() {
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
Function();
// bunch of code
}

Any help would be appreciated, any site(s) covering this because I've googled a lot but haven't found things that are relevant. Unless it's me using the wrong keywords.

Kind regards
brechtjah
brechtjah
 
Posts: 3
Joined: Thu Nov 06, 2008 3:50 pm

Postby MXP » Thu Nov 06, 2008 4:35 pm

Exact code and exact errors would are helpful in finding out what your exact problem is.

If you havent already, it might help to read the tutorials at Winprog.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby brechtjah » Fri Nov 07, 2008 12:38 am

Wow, I don't know what I was doing last night but calling a function works now. Sorry. I know this is offtopic but I'm still getting a console window for every application I execute, any ideas on how to fix this? Do I have to tell the compiler to compile it differently somehow?
brechtjah
 
Posts: 3
Joined: Thu Nov 06, 2008 3:50 pm

Postby MXP » Fri Nov 07, 2008 12:49 pm

Which IDE are you using? I'm going to assume you're using Dev-C++ since this shouldnt occur on Visual Studio, but in your project properties there should be a checkbox for creating a console window for your application. Code::Blocks might have something similar but I've never used it.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby brechtjah » Sat Nov 08, 2008 4:21 am

Thank you very much for your help : - )
brechtjah
 
Posts: 3
Joined: Thu Nov 06, 2008 3:50 pm


Return to Windows Programming

Who is online

Users browsing this forum: No registered users and 2 guests