|
well, guess what...
it does work, but partially
i explain:
when i do the following, it works :
this->FunctionsPage.m_psp.dwFlags |= PSP_USETITLE;
FunctionsPage.m_psp.pszTitle = "Environment";
but this doesn't :
this->FunctionsPage.m_psp.dwFlags |= PSP_USETITLE;
CString strCaption;
strCaption.LoadString(IDS_HELP_FUNCTIONS);
FunctionsPage.m_psp.pszTitle = strCaption;
while debugging, the strCaption variable is correctly filled with the right resource string, but the variable might be destroyed when living the scope.
actually, it works only if i hard code the string to display (which is exactly what i don't want)...
any idea ?
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Two ideas :
1. Try with
FunctionsPage.m_psp.pszTitle = strCaption.operator LPCTSTR();
2. Try with
strcpy(FunctionsPage.m_psp.pszTitle,strCaption.operator LPCTSTR());
Actually, as its name suggests, pszTitle is not a CString , so I presume you are right when saying the variable is destroyed after leaving the scope (In fact, you do a pointer assignment and the pointer is destroyed after leaving the scope).
If I am right, solution 1 will not even compile. So I bet solution 2 is what you are looking for.
~RaGE();
-- modified at 5:25 Thursday 2nd February, 2006
|
|
|
|
|
already done both.
let me add one note to your reply code however.
cast operators overloads are designed to be used as C-Style cast.
so instead of calling strCaption.operator LPCTSTR() , simply call (LPCTSTR)strCaption
anyway, this doesn't work either...
solution 1 actually compiles, but the tab caption displays strange characters (significative to our first diagnostic).
solution 2 doesn't compile ; the compiler says that it cannot convert parameter 1 from const char* to char* (and here, i don't understand why... )
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Hi,
I'd like to write a function, which returns an array of strings. But the size of the array is unknown. For example, it has to create a string array with the nos. I enter (say, "1", "2", "4", "9".. , and return back to the caller function when I enter 0. It has to grow dynamically. But I don't want to do it with built-in classes like list, vector and so on.
I'd like to use 'new' operator or 'malloc/realloc' functions.
Pls suggest me a good solution.
Thanks in advance,
Sarvan AL
|
|
|
|
|
|
Ever considered using STLs ?
~RaGE();
|
|
|
|
|
Google for the head line of your question: Dynamic memory allocation of 2-D array
I got 199000 hits, several of them uses malloc.
|
|
|
|
|
"malloc" should nowadays be replaced with "new" as my Cpp teacher told me recently
|
|
|
|
|
I quote the original poster:
"I'd like to use 'new' operator or 'malloc/realloc' functions.
Pls suggest me a good solution."
The original poster is totally free to use any technique available, as far as I'm concerned. I'm not responsible neither for the hits gotten from Google nor what sample the original poster uses.
But your teacher has got a point. In C++, it's preferred. I plain C, however, new() isn't available. And that's where malloc/realloc comes in, amongst others.
|
|
|
|
|
hi,
I want to display a little balloon tip on my tray icon but the balloon just won't appear, although the tray icon is visible. the app is based on MFC and here's the code that doesn't work. it is located in OnInitDialog:
<br />
<br />
ndata.cbSize=sizeof(NOTIFYICONDATA);<br />
ndata.hWnd = m_hWnd;<br />
ndata.uFlags = NIF_ICON | NIF_MESSAGE | NIF_INFO;<br />
ndata.uID = IDI_DISABLED;<br />
ndata.dwInfoFlags = NIIF_NONE;<br />
<br />
ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_DISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); <br />
<br />
ndata.uCallbackMessage = WM_POPUP;<br />
ndata.uTimeout = 10000;<br />
<br />
wcscpy(ndata.szInfoTitle,_T("Test"));<br />
wcscpy(ndata.szInfo, _T("Test")); <br />
<br />
Shell_NotifyIcon(NIM_ADD, &ndata);<br />
<br />
ndata is of type NOTIFYICONDATA and is a member of my dialog class.
any clues what could be wrong with that ?
greets
-- modified at 4:38 Wednesday 1st February, 2006
|
|
|
|
|
|
... no effect. setting the version didn't fix it
|
|
|
|
|
|
right after
ndata.cbSize = sizeof(NOTIFYICONDATA);
|
|
|
|
|
|
|
ok here's my new code:
<br />
ZeroMemory(&ndata, sizeof(NOTIFYICONDATA));<br />
<br />
ndata.cbSize = sizeof(NOTIFYICONDATA); <br />
ndata.hWnd = m_hWnd; <br />
ndata.uFlags = NIF_ICON | NIF_MESSAGE;<br />
ndata.uID = IDI_DISABLED;<br />
ndata.uCallbackMessage = WM_POPUP; <br />
<br />
ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_DISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); <br />
<br />
Shell_NotifyIcon(NIM_ADD, &ndata);<br />
<br />
ndata.uVersion = NOTIFYICON_VERSION;<br />
Shell_NotifyIcon(NIM_SETVERSION, &ndata);<br />
<br />
ndata.uTimeout = 10000;<br />
ndata.uFlags |= NIF_INFO;<br />
<br />
_tcscpy(ndata.szInfoTitle,_T("Test"));<br />
_tcscpy(ndata.szInfo, _T("Test")); <br />
<br />
Shell_NotifyIcon(NIM_MODIFY, &ndata);<br />
but still no balloon
|
|
|
|
|
|
|
yesss. that's it. i forgot the #define. ok man thank you! i appreciate your efforts!
|
|
|
|
|
Hi!
I have a dialog based application with severeal dialogs. There is a main dialog, which calls via Button and Menu all other dialogs.
Till now, I used only ordinary dialogs. But to make it more clear to the user, I tried to transform some of the dialog classes into PropertyPages. While using the dialog class, parameters were given to the main program while pressing the OK-Button.
Because there is no OK-Button in a PropertyPage-dialog, I don't know, how to give over the parameters now.
I Already implemented a function OnRefer(WPARAM, LPARAM), but only that was too less.
I already serached in the codeproject's articles but couldn't find something accordingly.
It would be great, if somebody could help me with this problem (Links, Hints or whatever)!!
Hanno
-- modified at 4:46 Wednesday 1st February, 2006
|
|
|
|
|
hanno25 wrote: parameters were referred while pressing the OK-Button
What do you mean exactely with "refer" ?
~RaGE();
|
|
|
|
|
Sorry about that, my mothertongue isn't the english language.
I want to say: to send parameters, to give over parameters. Is that a better expression?
Hanno
|
|
|
|
|
hanno25 wrote: to send parameters, to give over parameters
OK! I was not sure what you meant.
The idea behind the Property pages is:
You have a property sheet containing property pages.
You set up the property sheet, adding the property pages one by one, then the property sheet is called with a DoModal() from your base dialog. Now to exchange data between the property pages and your base dialog, you do the following:
The data you want to retrieve is saved in each property page in member variables.( I usually save everything in each property page in the OnDestroy() function, which is called when the property page is destroyed.)
Before doing the propsheet.Domodal() , you initialize all member variables of the property pages.
When the user clicks OK, the property sheet object still exist, and so do the property pages. You can then retrieve the data from the prop pages member variables.
A small code snippet:
CPage5Dlg page5;
page5.m_EnvList =m_EnvList;
page5.m_psp.dwFlags &=~PSP_HASHELP;
page5.m_AllowMultisession=m_AllowMultisession;
page5.m_AppendProject=m_AppendNewProject;
page5.m_psp.dwFlags| =PSP_USETITLE;
page5.m_psp.dwFlags& =~PSP_HASHELP;
page5.m_psp.pszTitle ="Environment";
CPage3Dlg page3comp;
page3comp.m_ShowLog=m_ShowCompilerLog;
page3comp.m_ShowComp=m_ShowCompilerWindow;
page3comp.m_CheckInno=m_CheckInno;
page3comp.m_DoComp=true;
page3comp.m_strarrNames.Copy(m_strarrNames);
page3comp.m_strarrOpt.Copy(m_strarrOpt);
page3comp.m_psp.dwFlags|=PSP_USETITLE;
page3comp.m_psp.dwFlags&=~PSP_HASHELP;
page3comp.m_psp.pszTitle="Compiler";
CPropertySheet Hello;
Hello.SetTitle("Settings...");
Hello.m_psh.dwFlags&=~PSH_HASHELP;
Hello.m_psh.dwFlags|=PSH_NOAPPLYNOW|PSH_USEHICON;
Hello.m_psh.hIcon=m_hIcon;
Hello.AddPage(&page5);
Hello.AddPage(&page3comp);
if (Hello.DoModal()==IDOK)
{
m_EnvList = page5.m_EnvList;
m_NamesArr = page3comp.strarrOpt;
}
~RaGE();
|
|
|
|
|
Use the PSM_QUERYSIBLINGS message that is designed for this purpose.
http://www.codeproject.com/property/Psm_QuerySiblings.asp#xx878390xx[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|