Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Win32 Tutorial Part 1 - MessageBox

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Freiza
Grandmaster Cheater
Reputation: 22

Joined: 28 Jun 2010
Posts: 662

PostPosted: Thu Feb 23, 2012 12:42 am    Post subject: Win32 Tutorial Part 1 - MessageBox This post has 1 review(s) Reply with quote

Code:
#ifndef UNICODE
#define UNICODE
#endif

#include<windows.h>


int WINAPI wWinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, PWSTR szCmdLine, int nCmdShow)
{
MessageBox(NULL,L"Body Message",L"Title Here",MB_OK);
return 0;

}


windows.h is a header that contains other important Header file. And is important if you want to create windows application.

WINAPI is a calling convention that specifies how the arguments are received by the function. Here the arguments are received right to left.
And it also specifies that the calling function is responsible for cleaning stack. (If you didn't understood a bit, do not worry as it is not important now. just remember to write it.)

wWinMain is an Entry function name similar to main() function in C.

hinstance is a handle(variable) to program running instance. It is a unique number assigned by operating system.

hprevinstance is always null. It is not used in Win32 systems.

szCmdLine is pointer to command line string.

nCmdShow is a parameter that controls how the window should be displayed on screen (i.e. maximized, minimized). We will discuss it later.

MessageBox is a function that shows a minimal dialog box.
First parameter is handle to owner of this MessageBox. In our program there is no owner of this MessageBox. More about owner window later. Since there are no owner of this window the first parameter is passed NULL.

Second Parameter is the message to be displayed.

Third Parameter is caption or title message of the MessageBox.

Fourth Message is a defined constant that represents OK button .



Important Typedefs:

typedef HANDLE HINSTANCE; //HANDLE is void*
typedef WCHAR *PWSTR; // WCHAR is wchar_t


Note:
wchar_t is UNICODE equivalent to char datatype.
Ex:-

char a = ‘m’;
wchar_t a = L’a’; //L is used to denote that ‘a’ is Unicode character and not an ASCII character.

WCHAR A =L’a’; // same as wchar_t


char a[100]=”hello world”; // ASCII String
wchar_t a[100] =L”hello world”; // Unicode string
WCHAR a[100] == L”hello world”; // WCHAR is just typedef of wchar_t



strlen(a); //returns the length of ASCII string;
wcslen(a); // returns the lenght of Unicode string;

Rule:

For string functions
strcmp --> wcscmp (ASCII --> Unicode)
strcpy --> wcscpy (ASCII --> Unicode)
strcat -->wcscat (ASCII --> Unicode)
....
....
etc.

<string.h> --> <wchar.h> (ASCII --> Unicode)
Back to top
View user's profile Send private message Send e-mail
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6223
Location: /dev/null

PostPosted: Thu Feb 23, 2012 1:41 pm    Post subject: Reply with quote

Surely you dont need a new thread for each part. It's beyond simple
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites