Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCListCtrl::GetItemData() Problem Pin
lpvoid7-Jan-03 5:39
lpvoid7-Jan-03 5:39 
Generaldisplay a jpg Pin
Didaa7-Jan-03 3:35
Didaa7-Jan-03 3:35 
GeneralRe: display a jpg Pin
Gary Kirkham7-Jan-03 5:01
Gary Kirkham7-Jan-03 5:01 
GeneralRe: display a jpg Pin
Davide Pizzolato7-Jan-03 11:05
Davide Pizzolato7-Jan-03 11:05 
GeneralRe: display a jpg Pin
Jason Henderson7-Jan-03 11:29
Jason Henderson7-Jan-03 11:29 
GeneralMy paranoia Pin
georgiek507-Jan-03 2:47
georgiek507-Jan-03 2:47 
GeneralRe: My paranoia Pin
Maximilien7-Jan-03 3:17
Maximilien7-Jan-03 3:17 
GeneralRe: My paranoia Pin
Alvaro Mendez7-Jan-03 5:19
Alvaro Mendez7-Jan-03 5:19 
georgiek50 wrote:
When I declare local variables in Dialog Procedures or even WndProc (that go before WM_INITDIALOG and WM_CREATE) do they need to all be static so they don't get declared again.

Only declare variables as static if you need to preserve their values between function calls. If the value is used temporarily inside the function, then just leave them as local (auto) variables.

georgiek50 wrote:
I don't quite understand how these functions work / get called. For example a dialog procedure gets called many times but does it end between those different calls or does the function get stuck in the message loop until the user terminates the dialog?

It gets called many times, or more accurately, every time a message is sent to your dialog box. It behaves just like any regular function call, the difference is that it's Windows that calls it for you.

georgiek50 wrote:
Either am I be safe by using HWND hwnd, or int iNumber or do I specifically need to declare them as static? I learned Win32 from Petzol's book and I noticed he doesn't declare everything as static and I am quite confused as to which variables should be static and which not. Anyone have any advice for me?

Again, just think of static variables as variables that are defined only once and then stay around forever, until the program ends. Compared to regular (local) variable, they offer no performance benefit. They actually cause your program to consume more memory since they don't go away until the program ends. Local variables are only loaded into memory when they're needed, such as when the function is called, and then their memory is automatically reclaimed.

Note that neither of these types of variables cause memory leaks. Those are caused by memory that's repeatedly allocated on the heap (with malloc), and never freed. This causes the program to eventually run out of space on the heap and crash.

Regards,
Alvaro


Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
GeneralRe: My paranoia Pin
georgiek507-Jan-03 6:26
georgiek507-Jan-03 6:26 
GeneralPropertySheet Pin
mzakarni7-Jan-03 0:42
mzakarni7-Jan-03 0:42 
GeneralRe: PropertySheet Pin
Abbas_Riazi7-Jan-03 0:49
professionalAbbas_Riazi7-Jan-03 0:49 
GeneralRe: PropertySheet Pin
mzakarni7-Jan-03 2:05
mzakarni7-Jan-03 2:05 
QuestionWhy disables my program Drag&Drop after running some time ? Pin
pma7-Jan-03 0:00
pma7-Jan-03 0:00 
Answerhadle limits? Pin
AlexO7-Jan-03 2:45
AlexO7-Jan-03 2:45 
GeneralRe: hadle limits? Pin
pma7-Jan-03 3:37
pma7-Jan-03 3:37 
QuestionHow to insert a CView in another CView? Pin
Ivano6-Jan-03 23:30
Ivano6-Jan-03 23:30 
AnswerRe: How to insert a CView in another CView? Pin
AlexO7-Jan-03 2:47
AlexO7-Jan-03 2:47 
GeneralRe: How to insert a CView in another CView? Pin
Ivano7-Jan-03 2:54
Ivano7-Jan-03 2:54 
QuestionGet pointer to document in a SDI from everywhere? Pin
loic6-Jan-03 23:19
loic6-Jan-03 23:19 
AnswerRe: Get pointer to document in a SDI from everywhere? Pin
MVH7-Jan-03 2:49
MVH7-Jan-03 2:49 
GeneralRe: Get pointer to document in a SDI from everywhere? Pin
loic7-Jan-03 4:23
loic7-Jan-03 4:23 
QuestionGetting the include directories??? Pin
Franz Klein6-Jan-03 22:23
Franz Klein6-Jan-03 22:23 
AnswerRe: Getting the include directories??? Pin
Todd Smith7-Jan-03 5:33
Todd Smith7-Jan-03 5:33 
GeneralRe: Getting the include directories??? Pin
Franz Klein7-Jan-03 23:11
Franz Klein7-Jan-03 23:11 
Questionhow to call a user defined dialog from the menu Pin
boby126-Jan-03 20:21
boby126-Jan-03 20:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.