|
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
|
|
|
|
|
SPowers wrote: 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.
Tying communication processes closely with GUIs is not a good idea. Neither will ever perform optimally. If this is your own code, I would rewrite it so that the socket's receive is caught in a separate thread that spawns an event for your GUI to catch (either using an Event or a Windows Message).
If you absolutely must leave it the way it is, try increasing the buffer size for the data you pull in the OnReceive handler.
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
|
|
|
|
|
Would switching to an event based socket help at all?
Following your design could I create a socket to receive and one to send and only put the receive side of the socket within the thread? My gut tells me that this would be impossible but then again this is the first socketed app I've made.
I only say this because the only part of the app where I'm worried about performance is on the receive end of the socket. I would only send about 20 packets per execution of the app and receive 20 million (which just fill up a buffer)
|
|
|
|
|
SPowers wrote: Would switching to an event based socket help at all?
In a single-threaded app, not really. From what you are describing, you are spending a lot of time processing GUI events, which keeps the socket's OnReceive handler from doing its job.
SPowers wrote: Following your design could I create a socket to receive and one to send and only put the receive side of the socket within the thread? My gut tells me that this would be impossible but then again this is the first socketed app I've made.
Generally, I usually stick the socket operations completely in a separate thread. The send calls don't gain much of a benefit from this, but it does keep the socket operations grouped together logically (e.g. makes it easier to understand the code).
Its been a while since I looked at it, but I believe that is what I did in the code for
this article. The article itself is about something completely different, but I used communication code I had written as part of the demo. That should at least give you a starting place, though.
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
|
|
|
|
|
Hello,
I am a beginner to intermediate programmer with understanding in OpenGL and C++, along with other programming languages. I have read over several "tutorials" on creating a DLL and calling a function from within the DLL. I have also read several "tutorials" on creating a screen saver. I have a basic understanding of how to do each of these. But what I am wanting to do is create a screen saver that basically just calls a dll that then runs the graphics calculations and such. Here is the general description of what I am trying to do, and then I'll give a more spcific question of what help I am looking for.
I am wanting a way to see my OpenGL graphics creations. So I figure that a screen saver of what I create would be great. So I am wanting to create a screen saver that is a shell of sorts. All it does is access a dll that has all of the graphics code in it. Then I can just update my dll and the screen saver will automatically be updated. So I need to figure out a way to create a dll that bascially has a "WinMain" function in it so that it will run my graphics. Eventually I want to pass in a variable to the main function so that I can specify which effect I want to be displayed.
So here is my question:
How do I create a dll that has it's own "WinMain" function so that I can just call one function in the dll and it will run as if it were it's own program? Or can this even be done?
I am not looking for someone to do this for me but to rather give me some terms to look up or better yet a simple example. I appreciate any help you guys can give me. Thanks for the help.
Maybe if I can get it figured out I will write up an article and submit to CodeProject for others to use, with references to those that helped me figure it out of course.
~REasley
Conquering the world one bit at a time.
|
|
|
|
|
reasley wrote: How do I create a dll that has it's own "WinMain" function...
Search for DllMain() .
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Thanks. I just found that function, finally, on the MSDN site. One question I have on this function though is that if I use this function as if it were a WinMain function and put a loop in it to process graphics animations, is there a way to gracefully close the dll when the screen saver turns off? For instance, when the mouse is moved the screen saver should exit, but if the dll has a graphics processing loop in it's DllMain function, will the screen saver still receive the exit notification? And if it does, I would guess that then I would want to call the FreeLibrary function to release the dll, or possibly the FreeLibraryAndExitThread function so that it closes the screen saver as well. But will I be able to release the resources created by the dll or is it done automatically when the FreeLibary function is called? I did not see any type of "WinProc" funciton for the dll so that I can process messages.
~REasley
Conquering the world one bit at a time.
|
|
|
|
|
reasley wrote: ...if I use this function as if it were a WinMain function and put a loop in it to process graphics animations...
Not a good idea. It should be treated as a get-in-and-get-out-quickly function. Why don't you just export a function that can be called whenever you are ready for the work to start?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
I am still learning the ins-and-outs of using dlls and was not sure if I could even do what I was wanting to do. This helps, now I know that I can't, or shouldn't, use the DllMain function as a WinMain replacement. Thanks I will start looking for an alternative method.
~REasley
Conquering the world one bit at a time.
|
|
|
|
|
reasley wrote: Thanks. I just found that function, finally, on the MSDN site. One question I have on this function though is that if I use this function as if it were a WinMain function and put a loop in it to process graphics animations, is there a way to gracefully close the dll when the screen saver turns off? For instance, when the mouse is moved the screen saver should exit, but if the dll has a graphics processing loop in it's DllMain function, will the screen saver still receive the exit notification? And if it does, I would guess that then I would want to call the FreeLibrary function to release the dll, or possibly the FreeLibraryAndExitThread function so that it closes the screen saver as well. But will I be able to release the resources created by the dll or is it done automatically when the FreeLibary function is called? I did not see any type of "WinProc" funciton for the dll so that I can process messages.
For what you want, you don't want to use DLLMain. DllMain basically initializes the dll. You can pretty much leave the default code the wizard gives you in it alone. What you will want is to create a function that will spawn a thread to do operations. That thread will need to keep an event handle and check it periodically to see if it needs to exit. To cause the thread to exit, you will call a separate method that will trigger the event.
The basic flow will look like this:
In the main application (pseudo-code)
<br />
LoadLibrary("MyDll.dll")<br />
MyStartFunc = GetProcAddress("Start")<br />
MyStopFunc = GetProcAddress("Stop")<br />
<br />
MyStartFunc()<br />
<br />
MyStopFunc()<br />
<br />
FreeLibrary(MyDll)<br />
In the Dll
<br />
MyEvent = NULL<br />
<br />
function Start<br />
[<br />
MyEvent = CreateEvent()<br />
StartThread(MyGraphicLoop)<br />
]<br />
<br />
function MyGraphicLoop<br />
[<br />
if (MyEvent is Triggered)<br />
exit<br />
else<br />
RenderGraphics()<br />
]<br />
<br />
function Stop<br />
[<br />
TriggerEvent(MyEvent)<br />
]<br />
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
-- modified at 16:31 Wednesday 31st May, 2006
|
|
|
|
|
That is great to know! So I can still have all of my code in the dll I just use the dll to spawn a thread that will do the rendering/calculation loop. That doesn't sound to difficult to do. Thanks a lot Zac and everyone else who responded.
~REasley
Conquering the world one bit at a time.
|
|
|
|
|
I am using Visual Studio 2005 Standard, C++.
How to set IDE for Multithreading?
Some say Properties /Code Generation, but I don't see on my IDE.
Could anyone help me?
Thanks!
Yonggoo
|
|
|
|
|
Yonggoo wrote: How to set IDE for Multithreading?
Uuh ? What do you mean exactly ? There is not such thing as 'IDE for multithreading'.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Yonggoo wrote: I am using Visual Studio 2005 Standard, C++.
How to set IDE for Multithreading?
Some say Properties /Code Generation, but I don't see on my IDE.
Could anyone help me?
Thanks!
That is where it is in VC6. You just need to select the multithreaded libraries. There is a drop-down list (can't remember where in the .Net versions) that allows you to select "Debug", "Debug Multithreaded", "Single Threaded", etc. Select the proper multithreaded library.
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 found it!
In Visual Studio 2005 Standard IDE, there is option about multithreaded.
In general condition,
Properties/configuration properties/C/C++/code generation/runtime library
But, in some conditions that option is not available,like when we chose 'empty project'.
As long as I know!
Thanks!
Yonggoo
-- modified at 16:57 Wednesday 31st May, 2006
|
|
|
|
|
Using Vis C/C++, Vis Stu 6.0
I am writing code for PCI communications.
I need to loop around at 1000Hz or so to
check for incoming data.
Looping with Sleep(1) puts a 15.6 millisec
delay, so it seems as if it uses the
nefarious Tick Timer. This is way too slow
for this app.
Is there any way to make precision timing,
or sleep with true resulution at 1 millisec
or smaller?
Many thanks,
Robert
|
|
|
|
|
Robert Palma Jr. wrote: Is there any way to make precision timing,
or sleep with true resulution at 1 millisec
or smaller?
No, because Windows is not a real-time OS. See here for more.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|