ror202015, (C++ Wina2 API Tutorial | Inferno Development
eM ladle)
DEVELOPMENT
(C++ Win32 API Tutorial
(0117-28 Baran Oral @ 437 pr GT
‘Yu may have steady done site bit of console programming with C++, Alhough, you probably wondered how
they gt tos rice graphieal use Interfaces (GUI in widows programs that sort have a black seen, Wel,
these GUI programs ar aled Win2 API programs, Leam how fo make bons, window, tox oss and nor
{GUL ebecten Windows 32 programing,
to make wonder Winsows Appears,
The mast common wins messages are WM_CREATE, WM_DESTROY, and WM_COMMAND. WN Stands for
Windows Message. CREATE hands the ial message ale prgran recles Upon esta ea i) te
wiedowa opeaing syste" process, You can add met of you GLI cada inside WM. CREATE, and any cher
(ur feat exe wl erate a window wih one ton ta wl popup a message bor whan clicked
fo32 AP wih you program.
We tnen decir a prototype Window recadue fonction dating sean LRESULT CALLBACK, which just a
Windows data ype for certain unctons. A prototpe I function thats dened at te top but wil be declare ater
{nin the arog, so you wil eth same functon again but wih actual code ste. Wo daca the arguments or
HANDS aro usualy uses fr GU elements hey rpresent ho actual Widow or window elms of @ program
UINT ear uneqnedintagar ana WPARAM and LPARAM ara paramstr msesages hat windows use oad mote
ats iio a meesone
\WINAPI WinMain Function
(we defekt con on sone pater */
‘tcl alen Standen wus 1 oo cao
hp siwww infernodevelopment conve-win32-apttutorial
Forum Community
Y
Follow me ont: }
aa
(scares
Popular content
All
1 4S credible Future Sif 20 hy
Cinema 40 (C40)
«Harvard scintatsdiacover protein GOF-1,
Got Free Updates
(Subscribe)
Updated Content
Sign Up | Losin
1srorzar2015, (C#+# Wina2 API Tutorial | Inferno Development
Pine tinann's defn color othe bcp of te Fina *
Lr tester the wo cosy on AF 6 foe the roan */
Wie deine our Ween program, which sa special uncton tha windows OS recognizes. We declare the HIND of
courmats progam, which tbe main window of he progran. We ten dadare the MSG of aur program thal wo wil
set rate our Windows messape oop. In adn, we cesta the object of WNOCASSEX whic the stucture
edt register ome data abou our program n Windows OS,
Message Event Loop For Windows
[Aor we dino our data, wo rgister our dass and chock for ay aos
d
he erenessxetstes fr saraton */
Ea na high te pses */ .
‘ated Ce
1 han the espe pe Ew ra art atenage) eaten 8 */
Gane etassige oneness 9, 8)
(1 tanslotevrtoey messes te haacer espe
‘he at tae Postgtemsone) gave */
le use CresteWindowx ould our main widow GUL We deine some information abou what kn of window
We nen show the wedow, upd
1 begin ou massape loop 29 tal ou progam ean actualy cammuniale
Windows Procedure Callback
CAT eA ae winaroce (8 an, IMT wasn, Me wan, Pai cm)
ott owen
Sates) (Pte a rds tssges */
se ema
= aotear)
se an
>
ce es
The Window Procedure uncton isthe Win32 AP way of sending and receiving Windows messages deleted a8
‘Wis deine the actual uncon tha we potted salar in the rogram. Wo erate an HWYND forthe ton and
oot each of ou window mossages and proces them,
In WM_COMMAND, we use a sth ok
‘he LPARAM and WPARAM paranelrs. an cise what
command has boon sant to us and about whch contol. ifwe recive the crretmessae hat sas our btn
as clicked, wo show a massage box
In WM_DESTROY, we dace PostQuitMessage(0), 6 ox ou program. This message is ntvale’ when he X
Window Message Create
hip sw infernod
26rorzar2015, (C++ Wina2 API Tutorial | Inferno Development
‘Sniton« cestenindoat, Lo sore on eters tyes */
Tents fot cantar
selon iss trrussuren, 7 coer eyes separates by
is AEE restates foe tft) */
* (toe vesrtcn (ost foe Yn) “7
eau, Pear Fe Zea +
ce DSelicat an toro
stu;
>
>
‘feu eabed whan 2 message comes thal we donot wan tohandl, Of couse a ne and of cur rogram we
Some C+ and Wind Data typ
Datatypes
Aatstypes ae ise fmol te sae a8 Ci daatypes. You ae ee fuse stadia C++ datypes fo oxpross any
Wi datatypes. Alot of to datatypes in Wi AP. are sony an are not ral that mprant to know, ut
sive you a quick reference anyway
-BOOL i 2 wows datatype that an equal rprosontton of ho simp boo usd in G++ ts vab can star
be to fe
-WORD This 16-5¢ntoger, that is smi ong. Specially use or some windows functions Ris ho
‘equivalent of unsigned shot in C+
“FLOAT eho equtvaent of eat Cr
“MINT isthe equtaent of unsigned int n Co
“WINAP!, APIENTRY, CALLBACK, APIPRIVATE, STOCALL ate all exact ne same a9 _
's te standard cain convnton.
-CDECL, WINAPV, ae both he same 8 _edect esting convanton ln C+
“FASTCALL isthe sme a8 —fastal cling convartonin C+
"PASCAL the sume as pascal eaing canventen Cr+
-WPARAM equate io an Unsigned int pointe, se uted in Windows Messages.
[LPARAM in Win32 API te use or Windows Messages, sang wit pref WM, bul actualy 2 porto a
INT Slandar rtoger datatype, sae a8 nts C+* (on).
SDWORD This sm LONG offong in stander Cr,
LONG i eit oN,
“HRESULT che exact equiva! fa og in C+
“HANDLE Ths slander lorginWs32 AP, bu usualy Used to neat @ GUI obec, rahi abject, or ame
[HWND This long used orale the window oboe taal, hence the name Win om)
-LPSTR Pointer oa string in V2
"LPCSTR This objets ong ponte to» constant sng
“LPTSTR This ng porriseqavalent fo LPSTR. but here are to verslors oft fncton, oe expecting an
[ANSI sting, and he one expecting a Unicse sng,
“LPCTSTR Thies combination of TCHARS m an LPTSTR. can conan unicode or ANS
ning Win32 API C++ Programming
Ipslimedn microsoft comlibrary
wed to make this ura as spe as posse to fallow for beginers and aso enough exams for many of you
to understand the suture ota windows program However, maura hone wl have many quastonssbout he
‘ous uncle and datatypes
‘You may nave aready done quts bit afconole programming with Gee, Athough, you probed wendared now
they gat nese nice graphical use interfaces (GUI) n windows progr hat dont heve aback sre. Wal
these GUI programs ate called Win32 API progrars
Boageleg6
hp siwww inferodevelopment conve-win32-apetutorial a6rorzar2015, (C++ Wina2 API Tutorial | Inferno Development
Anonymous (rot da blond heed
ery ,
Reply Quote
Nice, Just Starting To Learn
date rt Nie,
voc) targa a abot he wince SOK pac
‘nous be awesome of youd the source cade for dowmload) ven how sin
much)
Reply Quote
@Apollos, 1) COLOR_BTNFACEH
Aug 2010
@hooles,
) COLOR_BTNFACE+1 is COLOR_BTNSHADOW, ust a drkor shade ofthe
tat ray. eally up to you what you wantto de, Make sure +s inthe
parenthees otherwise wl tm BLACK,
2 Tthink the code wat hor to chee #IParam docs oi which it hou
‘Sometimes Param is rured fora socton of ode nthe Grampa above, he
shoreut you species could wor re,
yeorike (not raat Tutor, alpa @buneh, Thankyou.
‘roa
Post new comment
‘mronyrous
he con ti epee andl note hon punky yuna a Gravatar sun arcade on
Homepage:
hp sw infernodo 46ror2ar2015, (C++ Wina2 API Tutorial | Inferno Development
4
Luggage Bags
ge steaton Lom pla. Froe tipping. uy Now
hip siwww inferodevelopment conie-win32-apetutorial
56