|
Immunity18 wrote: file.ReadString(buf,100);
Why use char here? A CString object (e.g., LString ) is a much better choice.
If you are changing the contents of a .ini file, why not use the appropriate functions?
GetPrivateProfileString()
WritePrivateProfileString()
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
i'll try that althought its first time i hear about these functions ( i am a (very) bit newbie
|
|
|
|
|
Hi all =)
Is there a way of forcing the operator new to fail?? I need to test something...
Best regards [[]]
hint_54
-- modified at 18:06 Wednesday 31st May, 2006
Oh.. and one more thing =D
If I overload the operator new then the class constructors will not be called when memory is allocated for them. How do I make it call the constructor?
Peace =)
hint_54
|
|
|
|
|
hint_54 wrote:
If I overload the operator new then the class constructors will not be called when memory is allocated for them. How do I make it call the constructor?
Placement new? new (ptr_to_memory) Class(args)
--
100% natural. No superstitious additives.
|
|
|
|
|
Overloading the new should not effect whether the constructor is called.
Steve
|
|
|
|
|
Yes.. It's working now, but it didn't work at first.. Don't know why..
regards
hint_54
|
|
|
|
|
hint_54 wrote: If I overload the operator new then the class constructors will not be called when memory is allocated for them.
How are you verifying this?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I add a printf to the constructor.
But I don't get it.. it wasn't calling it and now it is! It must have been something else..
regards
hint_54
|
|
|
|
|
I am using this code to create a modeless dialog.
dlg.Create(CMainDialog.IDD, GetDesktopWindow());
dlg.ShowWindow(SW_SHOW);
However, It closes the modeless dialog as soon as it opens. Why is this? I get the debug message "Warning: calling DestroyWindow in CDialog::~CDialog --OnDestroy or PostNcDestroy in derived class will not be called"
Sorry for another stupid question. I swear I will catch on sooner or later.
Hey Maybe it will give you a chance to feel good about being able to answer an easy question, though make me feel even more stupid
-Brandy
|
|
|
|
|
Are you istantiating the dlg object inside a class method? If so, the problem is that as soon as the method exits, the dlg object gets destructed and your dialog is gone. The dlg object needs to live as long as you want the dialog to be displayed.
|
|
|
|
|
So where exactly am I suppose to declare it? I have tried placing it in all differnt locations and it says all of them are illegal.
|
|
|
|
|
Try:
CMainDialog *dlg = new CMainDialog;
dlg.ShowWindow(SW_SHOW); When you are done with it, call dlg->DestroyWindow() . Be sure and override PostNcDestroy() and delete the this pointer.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
That worked very nicely. Thanks a lot.
~Brandy
|
|
|
|
|
MDI project. User opens a few child windows.
And now I have to react on changing active child window.
One of the dialog bars is displaying some text and stuff that is unique for each document.
I have to change contents of this dialog bar when user is setting active other child window (I don't know if it calls "changing focus"?).
How can I do it?
~~~~
|
|
|
|
|
Luksky wrote: MDI project. User opens a few child windows.
And now I have to react on changing active child window.
One of the dialog bars is displaying some text and stuff that is unique for each document.
I have to change contents of this dialog bar when user is setting active other child window (I don't know if it calls "changing focus"?).
How can I do it?
CView::OnActivateView or CWnd::OnActivate
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I tried something like this, but it's not working :/
void CChildFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) <br />
{<br />
CMDIChildWnd::OnActivate(nState, pWndOther, bMinimized);<br />
<br />
BOOL bActivated = nState & WA_CLICKACTIVE;<br />
if( bActivated )<br />
AfxMessageBox("activate"); <br />
}
or like this
if( nState == WA_ACTIVE )<br />
AfxMessageBox("activate"); <br />
~~~~
|
|
|
|
|
Hello fellow men,
I am a former VB6 developer, turned VB.NET, turned C# developer. Now I'm facing troubles, cause I'm in for a big project that would be greatly weakened by a requirement to the end user, that a .NET framework would need to be installed.
Therefore, I've thought about immigrating to C++. How difficult would that be? How is the learning curve? How much time should I expect to put into it? What should I be aware of, when it comes to performance hits (going from a rapid ide to a non-rapid-ide) etc.?
Basically, I'd like to work with audio, file and network streams. And threading.
Any help, tips, guides or references to litterature would be greatly appreciated
PS. I hope this question hasn't been raised to many times before. At least, I didn't find any relevant posts in the search function.
|
|
|
|
|
matiasdk wrote: Basically, I'd like to work with audio, file and network streams. And threading.
Any help, tips, guides or references to litterature would be greatly appreciated
You are basically asking how hard it would be for you to go from a language that has these features pre-packaged for you, to one that gives you the ultimate flexibility with them (and are quite advanced topics at that). Going from C++ to any other language has a very small learning curve; not so for the other way around. The language syntax is similar to C#, but if you haven't been exposed to C++ before, I wouldn't try to jump into it with a project on a deadline.
As far as developing GUIs for your application, you won't notice much of a hit since Visual Studio has a very nice resource editor. However, you will notice that you don't get some of the cool features for free anymore (e.g. skinning, resizing controls when the window resizes, control arrays, etc).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I created a MFC application in Greek version Windows XP
and i have Greek font characters in my application.
Now when i run my application on another computre with non Greek Windows ,(you know what i see ) )(%$*&*JSDHF%&*#&
Is there any way to save my font in my application so it can work fine on non greek windows ?
|
|
|
|
|
Yes you can run your windows application where the greek font is not available.
Please do as follows.
1. Add the Greek Font file to your resource as a custome resource.
2. Durint he startup of your application the font added in your resource should be extrated to the a file in a directory ( may be your application direction ). Use the APIs FindResource amd LoadResource for this.
3. After extracting the font ot file to path ( eg: c:\Program Files\Your App\Font\greekfont.ttf ) call the windows API AddFontResource function with parameter as the path
eg:
AddFontResource ( c:\Program Files\Your App\Font\greekfont.ttf );
4. Now you can display the Greek Character in your application.
|
|
|
|
|
Well Said Bose..Keep going
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Ich wuerde Local COM port von meinem Computer suchen. Mein Computer hat nur COM1. Aber wenn ich mit enumport() meinen Computer sucht, zeigt folgendes Ergibnis: COM1,COM2,COM3,COM4 . Wie nutzt Man "enumport()". Mein code wie unten:
Email : wang_ba_de@yahoo.de
UsingEnumPorts(CUIntArray& ports)
{ports.RemoveAll();
DWORD cbNeeded = 0;
DWORD dwPorts = 0;
EnumPorts(NULL,2, NULL, 0, &cbNeeded, &dwPorts);
BOOL bSuccess = FALSE;
BYTE* pPorts = (BYTE*) _alloca(cbNeeded);
bSuccess = EnumPorts(NULL, 2, pPorts, cbNeeded, &cbNeeded, &dwPorts);
if (bSuccess)
{
PORT_INFO_1* pPortInfo = (PORT_INFO_1*) pPorts;
for (DWORD i=0; i<dwports; i++)
="" {
="" int="" nlen="_tcslen(pPortInfo-">pName);
if (nLen > 3)
{
if ((_tcsnicmp(pPortInfo->pName, _T("COM"), 3) == 0) && IsNumeric(&pPortInfo->pName[3], TRUE))
{
int nPort = _ttoi(&pPortInfo->pName[3]);
ports.Add(nPort);
}
}
}
|
|
|
|
|
English please.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
|
I currently have a MFC application in which I've already implemented CAsyncSocket as my socket class. I think this might have been a bad idea because it seems like onReceive messages are getting bogged down by general UI messages and it isnt running as fast as it should.
Is there another socket class that I could use to solve this problem?
I've considered moving my current socket to another thread so it would have its own message map but this would prove to be extremely difficult and would require a lot of rewriting of the appliction (which is something that I would like to avoid).
Would an Event based socket work better (WSAEventSelect)?
I should also say that the GUI and Socket are extremely intertwined. IE... a button click basically just sends a packet to my server and as I accept a packet I simply display it on the screen. This is why moving it to another thread would prove difficult.
-- modified at 15:51 Wednesday 31st May, 2006
|
|
|
|