Adding WTL support to existing app
-
Hi all, I have an application written in C++ using win32, it creates a few windows, has a menu etc. Nothing fancy. But it's becomming a major pain to add new windows, fancy controls and whatnot so I thought about using WTL instead of the raw API's. Is that feasible? The app works fine right now so I would like to create the new windows using WTL, the existing may be converted in the future. .Henrik --- Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
-
Hi all, I have an application written in C++ using win32, it creates a few windows, has a menu etc. Nothing fancy. But it's becomming a major pain to add new windows, fancy controls and whatnot so I thought about using WTL instead of the raw API's. Is that feasible? The app works fine right now so I would like to create the new windows using WTL, the existing may be converted in the future. .Henrik --- Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Yep, it's pretty easy.
- Remove your include of windows.h; instead, include atlbase.h, atlapp.h, then whatever other ATL/WTL headers you need.
- Right after the atlapp.h include, add
extern CAppModule _Module;
- In one of your CPP files, declare the global
CAppModule _Module;
- At the beginning of
WinMain()
, call_Module.Init(NULL, hInstance);
(where hInstance is the 1st param toWinMain()
).
--Mike-- Eh! Steve! Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me
-
Yep, it's pretty easy.
- Remove your include of windows.h; instead, include atlbase.h, atlapp.h, then whatever other ATL/WTL headers you need.
- Right after the atlapp.h include, add
extern CAppModule _Module;
- In one of your CPP files, declare the global
CAppModule _Module;
- At the beginning of
WinMain()
, call_Module.Init(NULL, hInstance);
(where hInstance is the 1st param toWinMain()
).
--Mike-- Eh! Steve! Homepage | RightClick-Encrypt | 1ClickPicGrabber "You have Erica on the brain" - Jon Sagara to me
Great, I'll give it a try. Thanks for the info. --- Any fool can write code that a computer can understand. Good programmers write code that humans can understand.