Displaying text on a Dialog
-
I have a Resource file from where Dialog takes the static content that i want to display. say LTEXT "Select",IDC_STATIC,.... where "Select" would gets displayed on to the dialog box on pop up But I don't wanna do this way ... Wat i want is smthng like LTEXT str_Data,IDC_STATIC,... where str_Data is of type CString and gets its value from a function say... str_Data = getData("Select"); and Function is CString getData(LPCTSTR); or sumthng like #define str_Data and LTEXT str_Data,IDC_STATIC,... and the rest remains same as above Do , anyone has any idea...
-
I have a Resource file from where Dialog takes the static content that i want to display. say LTEXT "Select",IDC_STATIC,.... where "Select" would gets displayed on to the dialog box on pop up But I don't wanna do this way ... Wat i want is smthng like LTEXT str_Data,IDC_STATIC,... where str_Data is of type CString and gets its value from a function say... str_Data = getData("Select"); and Function is CString getData(LPCTSTR); or sumthng like #define str_Data and LTEXT str_Data,IDC_STATIC,... and the rest remains same as above Do , anyone has any idea...
I dont understand what do you need?you have a file and you want to display content of this file with a static control,right?
WhiteSky
-
I have a Resource file from where Dialog takes the static content that i want to display. say LTEXT "Select",IDC_STATIC,.... where "Select" would gets displayed on to the dialog box on pop up But I don't wanna do this way ... Wat i want is smthng like LTEXT str_Data,IDC_STATIC,... where str_Data is of type CString and gets its value from a function say... str_Data = getData("Select"); and Function is CString getData(LPCTSTR); or sumthng like #define str_Data and LTEXT str_Data,IDC_STATIC,... and the rest remains same as above Do , anyone has any idea...
sorry for my poor English . It can't use variable directly in Resource file . If you want to do that , you can use a static content which ID isn't IDC_STATIC , and use SetWindowText to contrl the static content that you want to display in the dialog CPP. LTEXT "Select",IDC_STATIC_NAME,.... ... //dialog cpp ... GetDlgItem(IDC_STATIC_NAME)->SetWindowText("...");
-
I have a Resource file from where Dialog takes the static content that i want to display. say LTEXT "Select",IDC_STATIC,.... where "Select" would gets displayed on to the dialog box on pop up But I don't wanna do this way ... Wat i want is smthng like LTEXT str_Data,IDC_STATIC,... where str_Data is of type CString and gets its value from a function say... str_Data = getData("Select"); and Function is CString getData(LPCTSTR); or sumthng like #define str_Data and LTEXT str_Data,IDC_STATIC,... and the rest remains same as above Do , anyone has any idea...
That's quite easy... (Step 1) Change the ID of your static control to something other than
IDC_STATIC
. For exampleIDC_MY_TEXT
. (Step 2) You can set the text of your static control programatically at any place in your code (e.g. inOnInitDialog()
) with the following method:SetDlgItemText(IDC_MY_TEXT, "Here goes your text!");
The text can surely be a
CString
instance or the return value of yourgetData()
method.cheers, mykel
OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."
-
I dont understand what do you need?you have a file and you want to display content of this file with a static control,right?
WhiteSky
In VC++, you have a Resource file which has all the information regarding what ur dialog will contain , sumthng like this LTEXT "Click View ",IDC_STATIC,54,73,145,11 PUSHBUTTON "View Information",IDC_VIEW,254,165,56,16 Wat i want is instead of putting "Click View" in this file , can i declare a variable CString str_Data which gets its value from a function smthng like str_Data = FetchData(LPCTSTR); so wat i mean is : LTEXT str_Data, IDC_STATIC,54,73,145,11
-
That's quite easy... (Step 1) Change the ID of your static control to something other than
IDC_STATIC
. For exampleIDC_MY_TEXT
. (Step 2) You can set the text of your static control programatically at any place in your code (e.g. inOnInitDialog()
) with the following method:SetDlgItemText(IDC_MY_TEXT, "Here goes your text!");
The text can surely be a
CString
instance or the return value of yourgetData()
method.cheers, mykel
OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."
-
Thanx .... n wat abt Resource File ... do i have 2 make sum changes in that .... in LTEXT "",IDC_MY_TEXT,....
Sorry... what's your question? Please try to write valid English! :omg: Perhaps you meant something completely different but... you don't have to change your resource file (.rc and/or resource.h) by hand. I guess you're using Visual Studio. Open the dialog that contains the static control, select the static with the mouse and enter the new ID for the static in the properties window. Press return, that's it. Visual Studion changes your resource files (.rc and resource.h). Now you can use
SetDlgItemText()
to programmatically change the text of the static (see my previous post).cheers, mykel
OMM: "Let us be thankful we have an occupation to fill. Work hard, increase production, prevent accidents and be happy."