Advertisement

On-the-Fly?

Started by April 11, 2002 09:43 PM
5 comments, last by Wachar 22 years, 5 months ago
What''s the difference between initializing the windows struct paramters with the blah = blah and the just : blah? I heard the latter was called setting it on-the-fly. Is there any difference between setting them like this? ---------------------- Always will be smarter than you, --=ME=-- ----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
huh?
/*=========================================// Chem0sh// Lead Software Engineer & Tech Support// http://www.eFaces.biz=========================================*/
Advertisement
It says something about on-the-fly in Lamoth''s book. Top of page 74. I''ll show you...

Regular declarations.

  WNDCLASSEX winclass;winclass.cbSize = sizeof(WINDCLASSEX);winclass.style  = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;winclass.lpfnWndProc  = WindowsProc;winclass.cbClsExtra = 0;winclass.cbWndExtra = 0;winclass.hInstance = hinstnace;winclass.hIcon = LoadIcon(NULL, IDI_PPLICATION);wincalss.hCursor = LoadCursor(NULL, IDC_ARROW);winclass.hbrBackground = GetStockObject(BLACK_BRUSH);  


On-The-Fly

  WNDCLASSEX winclass = {winclass.cbSize = sizeof(WNDCLASSEX);//Then all of the things below except, without the winclass.//thingys and the name.  Like instead of hCursor = LoadCursor//(NULL, IDC_ARROW);, do: LoadCursor(NULL, IDC_ARROW).//It''s just taking out all the things before the = sign.};  


I heard that creating anything on-the-fly is bad. What''s the difference between the above and below examples?
Wachar's Eternity <-<-<-<-<- Me own site!
In the second version (on-the-fly, as you call it) you''re depending on the structure fields occurring in memory in a specified manner, and being byte-aligned the same as your code. Which, of course, you are not guaranteed. So don''t do it.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions ]
Thanks to Kylotan for the idea!
Ok, thanks!

----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
But, then, why do people use it?!


----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
Advertisement
Some people use it just for the speed increase in typing. I see no other benefit from its use.

And if Microsoft ever decides to change around their WNDCLASS data structure, and you happen to recompile using this new WNDCLASS structure, you are surely likely to get errors due to filling in the data structure improperly.






------

If I''m incorrect, sue me, you''ll get nothing
------Shop for the Lowest Price!Then, Check a Reseller's Rating Before You Purchase!

This topic is closed to new replies.

Advertisement