Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to get exact number of bytes accessible in RAM for a 32 Bit app? Pin
Erudite_Eric19-Sep-11 22:24
Erudite_Eric19-Sep-11 22:24 
GeneralRe: how to get exact number of bytes accessible in RAM for a 32 Bit app? Pin
Divya Rathore19-Sep-11 22:54
Divya Rathore19-Sep-11 22:54 
GeneralRe: how to get exact number of bytes accessible in RAM for a 32 Bit app? Pin
Erudite_Eric19-Sep-11 23:25
Erudite_Eric19-Sep-11 23:25 
GeneralRe: how to get exact number of bytes accessible in RAM for a 32 Bit app? Pin
Code-o-mat20-Sep-11 2:14
Code-o-mat20-Sep-11 2:14 
Questionupdating the label text Pin
sarfaraznawaz19-Sep-11 3:09
sarfaraznawaz19-Sep-11 3:09 
QuestionRe: updating the label text Pin
David Crow19-Sep-11 3:20
David Crow19-Sep-11 3:20 
AnswerRe: updating the label text Pin
sarfaraznawaz19-Sep-11 4:01
sarfaraznawaz19-Sep-11 4:01 
GeneralRe: updating the label text [modified] Pin
enhzflep19-Sep-11 4:34
enhzflep19-Sep-11 4:34 
When you create the window for the "0%" do you give it it's own unique ID, or juts use -1 or some other generic value. My reason for asking is that typically when creating a static control using a dialog/resource editor, the control gets an ID that can thwart an attempt to uniquely identify it later. (unless you maintain a global variable that holds the HWND of the static control)

The two approaches you may use are (1) maintain a global variable to hold the HWND of the control and (2) use a #define to give the static control a unique ID.

In the first approach you have the HWND already and just need to set the text, while the second approach means you need to retrieve the HWND by using the control id, before then going on to alter the text.

Approach 1:

C++
HWND globalPercentCompleteLabelHwnd;
globalPercentCompleteLabelHwnd = CreateWindow(WC_STATIC, "0%", windowStyle, xPos,yPos, width,height, hwndParent, (HMENU)-1, hInstance, NULL);
...
...
...
SetWindowText(globalPercentCompleteLabelHwnd, "Some new text");

Approach 2:
C++
#define IDC_PERCENT_STATIC 10001 // or any other arbitrary, UNIQUE id
CreateWindow(WC_STATIC, "0%", windowStyle, xPos,yPos, width,height, hwndParent, (HMENU)IDC_PERCENT_STATIC, hInstance, NULL);
...
...
...
HWND tmpCompleteLabelHwnd = GetDlgItem(hwndParent, ID_PERCENT_STATIC);
SetWindowText(tmpPercentCompleteLabelHwnd, "Some other new text");


Approach 1 relies on maintaining a global variable, while the second method implies a way of gaining access to the HWND of the control's parent - which you already have if changing the text inside the main WindowProcedure.

modified on Monday, September 19, 2011 10:40 AM

QuestionRe: updating the label text Pin
David Crow19-Sep-11 4:37
David Crow19-Sep-11 4:37 
GeneralRe: updating the label text Pin
Malli_S19-Sep-11 19:51
Malli_S19-Sep-11 19:51 
AnswerRe: updating the label text Pin
Richard MacCutchan19-Sep-11 4:03
mveRichard MacCutchan19-Sep-11 4:03 
QuestionDLL Pin
john563219-Sep-11 2:14
john563219-Sep-11 2:14 
AnswerRe: DLL Pin
QuickDeveloper19-Sep-11 2:36
QuickDeveloper19-Sep-11 2:36 
AnswerRe: DLL Pin
Malli_S19-Sep-11 2:43
Malli_S19-Sep-11 2:43 
GeneralRe: DLL Pin
john563219-Sep-11 21:55
john563219-Sep-11 21:55 
QuestionCan a VC++ application be converted to the web? Pin
DanYELL18-Sep-11 10:20
DanYELL18-Sep-11 10:20 
AnswerRe: Can a VC++ application be converted to the web? Pin
CPallini18-Sep-11 22:49
mveCPallini18-Sep-11 22:49 
GeneralRe: Try Windows Azure Pin
Software_Developer18-Sep-11 23:49
Software_Developer18-Sep-11 23:49 
GeneralRe: Replying to the OP Pin
Rajesh R Subramanian19-Sep-11 21:20
professionalRajesh R Subramanian19-Sep-11 21:20 
AnswerRe: Can a VC++ application be converted to the web? Pin
Erudite_Eric19-Sep-11 0:22
Erudite_Eric19-Sep-11 0:22 
GeneralRe: Can a VC++ application be converted to the web? Pin
Stefan_Lang19-Sep-11 0:31
Stefan_Lang19-Sep-11 0:31 
AnswerRe: Can a VC++ application be converted to the web? Pin
Orjan Westin20-Sep-11 2:28
professionalOrjan Westin20-Sep-11 2:28 
QuestionHow do I get recurring events from holding a button down? Pin
doug2518-Sep-11 7:51
doug2518-Sep-11 7:51 
AnswerRe: How do I get recurring events from holding a button down? Pin
enhzflep18-Sep-11 8:06
enhzflep18-Sep-11 8:06 
GeneralRe: How do I get recurring events from holding a button down? Pin
doug2518-Sep-11 8:49
doug2518-Sep-11 8:49 

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.