|
By the way gtsz[3][10] is too small. It should be gtsz[3][13]. (The strings really shouldn't be hard coded, but I assume this is a test app.)
And the problem as indicated above is that m_font is local and the font handle is being deleted. (The list control is robust enough that it recovers from this error.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
finaly, i found the answer, i should have declare m_font as a class member variable instead of a local variable, since i initiate the CListCtrl in OnInitialUpdate() and use it in another function. A local variable will go out of scope.
|
|
|
|
|
Hi
How can I change(set) the background color of my dialog box?
Thanks in advance
Taruni
|
|
|
|
|
Use SetDialogBkColor()
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
You should handle the WM_CTLCOLOR message.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi All,
I need to know how to set a default value in Combo Box. For example, right now I have a combo box with 3 times in it (Train, Bus, Both). I need to set "BOTH" as a default value in the combo box.
Thanks in advance
C++Prog
|
|
|
|
|
You can send the combobox a CB_SETCURSEL message (CComboBox::SetCurSel() in MFC).
Mark
|
|
|
|
|
Thanks a lot
Can I do it in 'Combo Box properties dialog'..or need to write a code for it?
C++Prog
|
|
|
|
|
Only at runtime, anytime after the Windows object (HWND) is created.
In response to the WM_INITDIALOG message is a good place
Mark
|
|
|
|
|
And...you'll want to do that AFTER you add items to the combobox!
Mark
|
|
|
|
|
I got it.....its working.....Thanks a bunch.
C++Prog
|
|
|
|
|
Here comes another thing...I need to do it dynamically. SetCurSel will make it static.
Thanks again
C++Prog
|
|
|
|
|
Preeti9 wrote: I need to do it dynamically. SetCurSel will make it static.
How so? It should just select/highlight the string, scrolling it into view if necessary.
|
|
|
|
|
o okay...I got it....
Thanks
C++Prog
|
|
|
|
|
|
I`m trying to write SDI MFC application with view class CRichEditCtrl. In my CMyAppView I used GetRichEditCtrl() to access the main RichEditCtrl. Now I want to create an independent class to write to RichEditCtrl lets call it CTextEditor.
What I don`t understand is how to tell the class to find CRichEditCtrl as I`m not able to use GetRichEditCtrl() outside the CMyApp class. I`ve tried to do something like:
<br />
int CTextEditor::WriteText(CRichEditCtrl *wnd,CString str,CHARFORMAT cf)<br />
{<br />
int nOldLines = 0, nNewLines = 0, nScroll = 0;<br />
long nInsertionPoint = 0;<br />
nOldLines = wnd->GetLineCount();<br />
nInsertionPoint = wnd->GetWindowTextLength();<br />
wnd->SetSel(nInsertionPoint, -1);<br />
wnd->SetSelectionCharFormat(cf);<br />
wnd->ReplaceSel(str);<br />
nNewLines = wnd->GetLineCount();<br />
nScroll = nNewLines - nOldLines;<br />
wnd->LineScroll(nScroll);<br />
return 0;<br />
} <br />
And then call it from CMyapView like this:
<br />
CHARFORMAT cf;<br />
cf.dwEffects = CFE_BOLD;<br />
cf.dwMask = CFM_BOLD;<br />
cf.cbSize = sizeof(CHARFORMAT);<br />
CTextEditor editor;<br />
editor.WriteText(&GetRichEditCtrl(),"Mytext",cf); <br />
But I get the unresolved externals error..
What am I doing wrong?
Please help - no clue bout how to use pointers...
|
|
|
|
|
Can you paste error text ?
|
|
|
|
|
Here`s what the build log says...
TestAppView.obj : error LNK2019: unresolved external symbol "public: int __thiscall CTextEditor::WriteText(class CRichEditCtrl *,class ATL::CStringT<char,class strtraitmfc_dll<char,class="" atl::chtraitscrt<char=""> > >,struct _charformat)" (?WriteText@CTextEditor@@QAEHPAVCRichEditCtrl@@V?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@U_charformat@@@Z) referenced in function "public: void __thiscall CTestAppView::OnPortOpen(void)" (?OnPortOpen@CTestAppView@@QAEXXZ)
C:\Documents and Settings\Raivo\My Documents\Visual Studio 2005\Projects\TestApp\Debug\TestApp.exe : fatal error LNK1120: 1 unresolved externals
|
|
|
|
|
It seems like, somehow CTextEditor class definition is not included in project. Just curious to know, whether you have added cpp containing CTextEditor in to your project.
Because, from error text, its seems so.
|
|
|
|
|
|
HakunaMatada wrote: Can anyone give me pointers on creating an Application without any UI?
If you hand me one of those beers I'll give you a pointer
The very simplest way would be to not show your app's main window.
Thanks for the beer
Mark
|
|
|
|
|
Mark Salsbery wrote: The very simplest way would be to not show your app's main window.
I know we can just hide the main Window but I was looking at a more elegant solution.
Mark Salsbery wrote: Thanks for the beer
You are welcome.
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
It’s rather simple to write an unmanaged C++ application that crashes when it performs a callback. It’s impossible to write a managed application that does the same, thanks to delegates. - Jeff Prosise
|
|
|
|
|
HakunaMatada wrote: but I was looking at a more elegant solution.
Console app with hidden console window.
A service application (but has to be run from the service manager).
What if you make a Win32 app and never create a window?
|
|
|
|
|
Mark Salsbery wrote: What if you make a Win32 app and never create a window?
I did try this and it seems to work. I created a message loop but didn't create any window. Would this affect the application in any way?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
It’s rather simple to write an unmanaged C++ application that crashes when it performs a callback. It’s impossible to write a managed application that does the same, thanks to delegates. - Jeff Prosise
|
|
|
|
|
I would think if it runs it's fine
As long as there's a way to terminate the process it shouldn't matter.
Windows service applications run just fine with absolutely NO UI. The only difference is the
added entry points so the SCM can control them.
You may not even need a message loop.
Mark
|
|
|
|