|
yse i see this problem well you can create controls dynamic
whitesky
|
|
|
|
|
Can one of you please post frequently asked Interview questions (with answers) for Multithreaded programming in C++/VC++
Thanks in advance!
|
|
|
|
|
15.Types of threads?
A.) There are 2 types of threads they are 1.) Worker threads (doesn’t have a message pump) —-> usually used for background processing like searching etc.
2.User Interface Thread(which has a message pump) can be used to create windows.
16.Is it possible to share the thread stack memory to another threadNO
17.Types of Syncronization Classes?
A.) CMutex, CSemaphore, CCriticalSection, CEvent
7.What is Serialization? Which macro is to be specified in the user-defined class, which will take part in serialization?
A.) Serialization is the process of writing or reading the contents of an object to and from a file. Include the macros DECLARE_SERIAL in the .h file
IMPLEMENT_SERIAL in the .cpp file
7. What are the parameters passed for IsLoading() and IsStoring() functions?
A.) No parameters are passed to both the functions.
6. What do u mean by the third parameter in IMPLEMENT_SERIALIZE?
A.) IMPLEMENT_SERIAL(class_name, base_class_name, wSchema);
The 3rd parameter is wSchema A UINT “version number” that will be encoded in the archive to enable a deserializing program to identify and handle data created by earlier program versions. The class schema number must not be –1.
• Base class of all the threads --> CWinThread
regards
kumar_windows
|
|
|
|
|
Thanks for your help Kumar!
Today I got some new things to learn!
|
|
|
|
|
|
Thanks for your timely help Laxman!
|
|
|
|
|
Hi
I am currently writting an installer for my project.
Instead of writting uninstaller I want to use the windows add and remove program to do it. How can I add my install informations in the "Add and remove program" list. Can you please give me some hint so that I can have a try.
Thanks
Regards
Anil
|
|
|
|
|
I am trying to use the EnumDisplayDevices function, but for some reason is giving me a undeclared Identifier:
#include <windows.h>
#include <iostream>
using namespace std;
void main()
{
DISPLAY_DEVICE dd;
DWORD i;
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
for(i=0; EnumDisplayDevices(NULL, i, &dd, 0); i++)
{
cout<
|
|
|
|
|
Hi
Though I can't exactly tell why the problem is occoring some of the resons are
UNICODE and WINVER definations. If you go to winuser.h you can see the defination of EnumDisplayDevice.
you can try as MSDN way. that is dynamically loding the funtion from DLL.
<br />
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)<br />
{<br />
FARPROC EnumDisplayDevices;<br />
HINSTANCE hInstUser32;<br />
DISPLAY_DEVICE DispDev; <br />
char szSaveDeviceName[32];<br />
BOOL bRet = TRUE;<br />
<br />
hInstUser32 = LoadLibrary("User32.DLL");<br />
if (!hInstUser32) return FALSE; <br />
<br />
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");<br />
if (!EnumDisplayDevices) {<br />
FreeLibrary(hInstUser32);<br />
return FALSE;<br />
}<br />
<br />
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));<br />
DispDev.cb = sizeof(DISPLAY_DEVICE); <br />
<br />
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0)) { <br />
lstrcpy(szSaveDeviceName, DispDev.DeviceName);<br />
<br />
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0); <br />
<br />
lstrcpy(lpszMonitorInfo, DispDev.DeviceString);<br />
} else {<br />
bRet = FALSE;<br />
}<br />
<br />
FreeLibrary(hInstUser32);<br />
<br />
return bRet;<br />
}<br />
<br />
Regards
Anil
|
|
|
|
|
Anil, Thank for your help, but this thing is starting to get on my nerves. I can not get it to work.
I try the above and nothing, then I try to simplify it and another error, see:
#include <windows.h>
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
{
FARPROC EnumDisplayDevices;
HINSTANCE hInstUser32;
DISPLAY_DEVICE DispDev;
char szSaveDeviceName[32];
BOOL bRet = TRUE;
hInstUser32 = LoadLibrary("User32.DLL");
if (!hInstUser32) return FALSE;
// Get the address of the EnumDisplayDevices function
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));
DispDev.cb = sizeof(DISPLAY_DEVICE);
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);
FreeLibrary(hInstUser32);
return bRet;
}
void main()
{
}
The error I get is:
error C2197: 'int (__stdcall *)(void)' : too many actual parameters on EnumDisplayDevices(szSave....)
I am thinking, I will not trying to get this function to work.
|
|
|
|
|
Anil, sorry for the above that says
#include it is missing <windows.h>
|
|
|
|
|
SOrry I did not know that this was taking HTML tags,
so the <> does not come out.
anyway it is #include <windows.h>
|
|
|
|
|
I have just copy and paste the above code from MSDN
any way this time I changed it in my way and comiled it. Hope it will work.
<br />
<br />
typedef BOOL (WINAPI* EnumDisplayDevices) (<br />
LPCTSTR lpDevice,
DWORD iDevNum,
PDISPLAY_DEVICE lpDisplayDevice,
DWORD dwFlags
);<br />
<br />
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)<br />
{<br />
EnumDisplayDevices pEnumDisplayDevices;<br />
HINSTANCE hInstUser32;<br />
DISPLAY_DEVICE DispDev;<br />
char szSaveDeviceName[32];<br />
BOOL bRet = TRUE;<br />
<br />
hInstUser32 = LoadLibrary("User32.DLL");<br />
if (!hInstUser32) return FALSE;<br />
<br />
pEnumDisplayDevices = (EnumDisplayDevices)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");<br />
<br />
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));<br />
DispDev.cb = sizeof(DISPLAY_DEVICE);<br />
<br />
pEnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);<br />
<br />
FreeLibrary(hInstUser32);<br />
<br />
return bRet;<br />
}<br />
<br />
<br />
void main()<br />
{<br />
}<br />
<br />
Regards
Anil
-- modified at 21:05 Tuesday 23rd May, 2006
|
|
|
|
|
Anil, THANK YOU VERYYYYYYYYYY MUCHHHHHH, YOU ARE ONE SMART PERSON, I REALLY WANT TO THANK YOU FOR YOUR HELP, I WAS ABLE TO USE THE CODE ABOVE AND IT WORKS. I JUST INCLUDED A COUT COMMAND TO PRINT OUT THE DEVICE INFORMATION. THANKS A LOT
if anything, this is how i change the code that Anil gave me, for other people looking at this question: [** I had the error for precompiler stdafx.h, so just go to settings and ignore the precompiler headers.]
#include <windows.h>
#include <iostream>
using namespace std;
typedef BOOL (WINAPI* EnumDisplayDevices) (
LPCTSTR lpDevice, // device name
DWORD iDevNum, // display device
PDISPLAY_DEVICE lpDisplayDevice, // device information
DWORD dwFlags // reserved
);
BOOL GetDisplayMonitorInfo()
{
EnumDisplayDevices pEnumDisplayDevices;
HINSTANCE hInstUser32;
DISPLAY_DEVICE DispDev;
char szSaveDeviceName[32];
BOOL bRet = TRUE;
DWORD i;
hInstUser32 = LoadLibrary("User32.DLL");
if (!hInstUser32) return FALSE;
// Get the address of the EnumDisplayDevices function
pEnumDisplayDevices = (EnumDisplayDevices)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
ZeroMemory(&DispDev, sizeof(DISPLAY_DEVICE));
DispDev.cb = sizeof(DISPLAY_DEVICE);
for(i=0;pEnumDisplayDevices(NULL/*szSaveDeviceName*/, i, &DispDev, 0);i++)
{
cout<
|
|
|
|
|
Hi ~
I have an Excel Chart embedded in my program in a MFC Dialog. The x-axis scale shows dates from a time range selected by the user. The data is then drawn on the chart.
My problem is that in some cases the x-axis scale is missing. With the same data and scale, the data sometimes appears. If I have it redraw 10 times, the data is there some of the time.
Any ideas on what could be happening?
Thanks in advance!
Jen
|
|
|
|
|
Did some work for a friend over the weekend. Basic scenario was that he had a client who wanted to have a program built that processed some numbers. He wanted a test app built in Java, C#, VB.NET and C++. My friend had already developed the C# app so he sent me the code and I translated to C++. Initial testing looked like the C# app was as fast and sometimes faster than the C++ app...in debug and release.
I found that true until I stopped writing to the console. And even more so when I used profile guided optimization. At that point the C++ app embarrased the C# app. And in the same way C# cuts in half the time for VB.NET. The client decided not to look at Java knowing it didn't stand much chance.
C++
Total Time: 25.47ms
Per Tick: 0.00029ms // note that I had to extend this just to see the result!
Per 50K Ticks: 14.62ms
C#
Total Time: 185.10ms
Per Tick: 0.0021ms
Per 50K Ticks: 106.23ms
Bottom line for me is that the heavy lifting still belongs to C++!!
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
|
May I ask which version of VC++ you used? Reason I ask is because my time comparisons between VC++ 6.0 and VC++ 2003(Native) showed that the VC++ 2003 code embarassed the code from VC++ 6.0. This was without using any optimized compiler or settings. (Turning the optimized settings on VC++ 2003 and playing with the compiler optimization switches yielded less favorable results for some odd reason)
Since C# is from a newer generation of compilers, comparing it with VC++ 6.0 might not be as impressive for C++ programmers as comparing C# with VC++ 2003.
For what it's worth.
Anyway, thanks for sharing the results
|
|
|
|
|
VS2005. I'm going to rewrite the code using C++/CLI just to see what it does. I'll put that up shortly.
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
FWIW, I am a bit surprised by this. I would hesitate to suggest that perhaps the C# app hasn't been optimised very well or written as well as it could have been. I would expect the C++ app to be maybe 2 or 3 times faster, but not 7.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I was shocked. I didn't think there would be much difference!
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
Hallo
so far i understood:
Using RegisterShellFileTypes() adds a string to the registry. So double clicking a file opens the app.
But the regkey ends up with \dde and i would like to have %1
What do i have to do ??
THX
Tim
-- modified at 19:27 Monday 22nd May, 2006
|
|
|
|
|
Errr... Does it actually work though. Using DDE is just fine. You shouldn't have to change anything.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I have a multi-threaded SDI app using VC++ 6.0 SP6 (MFC)
It has crashed multiple times without any sign of why. in other words it just closes. No memory exception, illegal operation, dr watson error, and nothing in the user.dmp file
Any ideas on what can cause a windows app to simply dissapear.
Thank you!!!!
John
|
|
|
|
|
I've seen this before. In my case it was caused by stack corruption breaking the exception handling chain (which is on the stack). I've got an application at home that intentionally reproduces the problem. When I get home I'll send it to you if you think it will be of any help.
Steve
|
|
|
|