|
Thanks, I'll give a try.
Vaclav
|
|
|
|
|
Hello,
In addition to what Micheal Dunn said, typedefs make your life more easy when you use templates extensively:
typedef CArray<double, double> CArrayDouble;
CArrayDouble* pArrayDouble = new CArrayDouble();
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Hey Friend
I have a dialog based MFC application with a Edit box. User can input TCL scripts into this Edit box. I want to add a feature in this, by which if a User types in a TCL script line starting with "#", then the entire line should change its color to Green. Because a "#" symbol in TCL is a comment symbol. I used OnChar() function to get the User input character, and i can recieve each character from key board.
The block for me in now is how to change the color of a character and then display it in Edit box. Can anyone please help me?
Don
|
|
|
|
|
This is the kind of stuff rich edit controls can do. See CRichEditCtrl::SetSelectionCharFormat() and the like.
"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!
|
|
|
|
|
I have already added the Edit box in my app, and added many functionalitites. If i remove the Edit box now and replace it by RichEdit, will it cause any problems?
Is there any simple sample application which shows how this can be done in RichEdit?
|
|
|
|
|
dipuks wrote: If i remove the Edit box now and replace it by RichEdit, will it cause any problems?
It should not cause any problems. You just have to make sure you set up the rich edit control properly. Call AfxInitRichEdit2() in your app's InitInstance(), and then call CRichEditCtrl::SetEventMask() so the control sends the messages you want to handle.
dipuks wrote: Is there any simple sample application which shows how this can be done in RichEdit?
You could look here[^] for examples, there may even be one that does exactly what you need.
"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!
|
|
|
|
|
I would suggest you to use control subclassing , just derive new CEditEx class from CEdit , and add SetTextColor method to it.
[CEditEx.cpp]
...
ON_WM_CTLCOLOR_REFLECT()
...
HBRUSH CEditEx::CtlColor(CDC* pDC, UINT nCtlColor)
{
HBRUSH hbr;
hbr = (HBRUSH)m_brBrush;
pDC->SetTextColor(m_clrTextColor);
return hbr;
}
...
void CEditEx::SetTextColor(COLORREF clrTextColor)
{
m_clrTextColor = clrTextColor;
Invalidate();
}
then simply override the WM_CHAR message handler of your Dialog
and use the m_editEx.SetTextColor(RGB(0,128,0)) method where needed.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Thanks for you reply.
I tried the way you have sugested. But SetTextColor will set the GREEN color to entire text in Edit box. Rather than doing to one single line.
Any other way of setting to single lines?
|
|
|
|
|
dipuks wrote: Thanks for you reply.
You are welcome
dipuks wrote: Any other way of setting to single lines?
In that case you'll need what PJ Arends suggested to you , look here[^] and here[^] they seem to be useful to you.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Hi!
After reinstalling my PC I downloaded the latest SDK (I used the "August 2002"-SDK before), installed it and set the directories to the SDK. When I try to compile my applications I get several errors, e.g. CWnd::KillTimer() does not exist. Has anybody the same problems? Or do you have any source for the "August 2002"-SDK (which worked quite well for me).
Ciao,
Alex
|
|
|
|
|
Its even worse. The new dll symbols are incompatible so you can not even debug your applications...
The same is true for the latest direct draw sdk.
John
-- modified at 19:39 Friday 23rd December, 2005
|
|
|
|
|
February 2003 is the last PSDK that works with VC6 - I haven't checked the SDK Update site in a while, but it might still be there.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Yes, as always, Mike is correct. However, the CD is labeled (Windows 2003 Server). I am running VC 6.0 on XP and since I installed this PSDK I have problems with MFC assertions. In about 50% of the time when assertion fails XP gets into the act and wants to send "serious problem " message to MS and VC does not stop properly. Needless to say - it makes development harder.
Happy festivus to all.
Vaclav
|
|
|
|
|
Is there a simple way of checking to see if an external application, say Microsoft Word, is already running before creating a new process via CreateProcess? Thanks!
|
|
|
|
|
Yes.
You can use FindWindow command (win32 api).
|
|
|
|
|
FindWindow
See EnumProcesses instead.
Marriage slows down your coding, a baby slows it down even more!
|
|
|
|
|
Blake Miller wrote: FindWindow
DAMM, FindWindow again!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
elephantstar wrote: Is there a simple way of checking to see if an external application,
look for Process32First and Process32Next apis
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks, that worked. I also have another question. I was planning on using AttachThreadInput() to bring the application to the front but I wasn't sure how to obtain the thread id. Any help is much appreciated. Thanks.
|
|
|
|
|
elephantstar wrote: was planning on using AttachThreadInput() to bring the application to the front
Any particular reason for using it !
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
elephantstar wrote: I was planning on using AttachThreadInput() to bring the application to the front
any particular reason to use that api..... anyway use CreateToolhelp32Snapshot with TH32CS_SNAPTHREAD to get thread list associated with it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
elephantstar wrote: I was planning on using AttachThreadInput() to bring the application to the front
any particular reason for using it,anyway use CreateToolhelp32Snapshot with TH32CS_SNAPTHREAD to get list of thread
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I'm using Visual Studio 2005. I'm trying to create a dynamic library for my MFC application. This library uses MFC via shared DLL and exports a class that contains functions using CString objects.
For example, I constructed a simplified library like so:
<code>#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif
class TEST_API CTest {
public:
CString DoStuff()
{
return _T("This is only a test.");
}
};
Simple enough, right? But whenever I try to link my application to this library and use the CString-related function, I get linker errors like the following:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: class ATL::CStringT<unsigned short,class ATL::StrTraitATL<unsigned short,class ATL::ChTraitsCRT<unsigned short> > > __thiscall CTestClass::DoStuff(void)" (__imp_?DoStuff@CTestClass@@QAE?AV?$CStringT@GV?$StrTraitATL@GV?$ChTraitsCRT@G@ATL@@@ATL@@@ATL@@XZ) referenced in function ....
I came across this article on Codeproject, wherein Nick Pirocanac recommends using CAtlString in the library instead of CString, but it was writen for Visual C++ 7, and it seemed to be addressing problems with ATL-based libraries and applications. I tried Nick's methods anyway, and they didn't seem to work.
I just recently migrated to Visual Studio 2005 from version 6, and of course this library worked just fine back then, before CString was template-ized. Now, the strange thing is that this problem doesn't seem to occur when I do a Release build. I scanned through the configurations, but I'm fairly new to VS8 and I couldn't find any difference between the configurations that would cause this.
Has anyone had similar problems, and more importantly, does anyone know how to fix this? I get the feeling it's something simple and obvious that will make me feel very stupid when it's explained, but I just have no clue right now. Any help would be most appreciated.
[Insert witty and relevant signature here]
|
|
|
|
|
I was going through the project options again and I found the culprit. Apparently I had turned off the "recognize wchar_t as a native type" option at some point in my MFC application. And all this time I'd been thinking it was MFC's / ATL's fault. I'm such a dummy sometimes. :P
[Insert witty and relevant signature here]
|
|
|
|
|
Mr. Accident wrote: I'm such a dummy sometimes.
Not at all. You continued to work on the problem, and when you found the answer, posted the solution here. Others can then benefit.
Software Zen: delete this; // <a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" rel="nofollow">Fold With Us!</a>[<a href="http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx" target="_blank" rel="nofollow" title="New Window">^</a>]
|
|
|
|