|
when i compile a program, an error occur,as below:
"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlconv.h(996) : error C2084: fucntion“LPDEVMODEA AtlDevModeW2A(LPDEVMODEA,const DEVMODEW *)”already Has a
body......."
is there anybody know how to solve this?
MS Visual Studio .net 2003
Windows Xp Professional SP2
Additional: Everything is ok under Windows2000
hello everybody!
|
|
|
|
|
Hi.
In visual c++ i want to create one class in order show algorithm sort by graphic.
Example sort: 1 4 6 5 8
I want to exchange 6 and 5 by graphic.
class CricleObject{
//attribute
int x, y, r;
int value;
//method
CricleObject();//constructor
CricleObject();
void moveLeft();
void moveRight();
};
In algorithm code:
//CricleObject array[10];
if (array[1].Value > array[2].Value){
array[1].moveRight();
array[2].moveLeft();
}
...
They are show by graphic.
Thanks.
-- modified at 22:11 Tuesday 11th October, 2005
|
|
|
|
|
you need to create few bitmaps probably, and use timers and gdi functions to move the images around.
Good luck.
-prakash
|
|
|
|
|
The following code is to enumerating the USB drives, But how can I get the corresponding drives label as it enumerating?
hDevInfo = SetupDiGetClassDevs((LPGUID)&GUID_CLASS_USB_DEVICE,
0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (hDevInfo == INVALID_HANDLE_VALUE)
return false;
DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i = 0 ; SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData) ; i++)
{
DWORD DataT;
LPTSTR buffer = new char[1024];
DWORD buffersize = 1024;
while (!SetupDiGetDeviceRegistryProperty(hDevInfo, &DeviceInfoData,
SPDRP_HARDWAREID, &DataT, (PBYTE)buffer, buffersize, &buffersize))
{
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
if (buffer)
LocalFree(buffer);
buffer = (char*)LocalAlloc(LPTR,buffersize);
}
else
break;
}
...
|
|
|
|
|
If/when you find the drive letter for it, use this code:
char buffer[MAX_PATH];
char driveNameBuf[MAX_PATH];
// Make sure the drive name ends with a backslash, else GetVolumeInformation() won't find it.
strcpy(driveNameBuf, "C");
if(driveNameBuf[strlen(driveNameBuf) - 1] != '\\') strcat(driveNameBuf, "\\");
// Or, simpler, use just "D:\\";
SHFILEINFO sh;
DWORD dw = SHGetFileInfo(
driveNameBuf, // LPCTSTR pszPath,
0, // DWORD dwFileAttributes,
&sh, // SHFILEINFO FAR *psfi,
sizeof(sh), // UINT cbFileInfo,
SHGFI_DISPLAYNAME // UINT uFlags
);
if(dw) strcpy(buffer, sh.szDisplayName); // Ok, create a good looking text line
else strcpy(buffer, driveLetterBuf); // Not Ok, create a less good looking text line
|
|
|
|
|
I mean how do I get the USB drive letter through
hDevInfo
or
&DeviceInfoData
|
|
|
|
|
I have a progress bar in my dialog with id IDC_WP_PROGRESS.
I have done the following. But still the progress bar is not working. The execution is not calling WM_TIMER at all. What am I missing????
BOOL CALLBACK DialogProc (HWND hDialog, UINT message, WPARAM wParam,
LPARAM lParam)
{
int nPos = 1;
HWND hProg;
hProg = GetDlgItem(hDialog,IDC_WP_PROGRESS);
switch (message)
{
case INIT_DIALOG:
......
case WM_TIMER:
{
if (wParam == IDC_WP_PROGRESS)
{
nPos = nPos+1 ;
SendMessage(hProg,PBM_SETPOS,(WPARAM)nPos,0);
}
break;
}
case WM_USER_MSG:
{
SendMessage(hProg,PBM_SETRANGE,0,MAKELPARAM(0,50));
SendMessage(hProg,PBM_SETPOS,(WPARAM)nPos,0);
int ret = SetTimer(hDialog,IDC_WP_PROGRESS,150,NULL) ;
if(ret == 0)
MessageBox(0, "Could not SetTimer()!", "Error", MB_OK );
......
}
..........
|
|
|
|
|
Are you absolutely sure the WM_TIMER is not posted?
It looks to me that since your nPos is a local variable, which is reset to 1 each time the function is called, you will never see a progress bar setting more than 2.
I would add an OutputDebugString for the WM_TIMER and make sure it is NOT getting called, since everything here looks okay, assuming you don't send WM_USER_MSG too often, which would constantly reset your progress bar and your timer.
|
|
|
|
|
Thanks for ur reply.
Ya I tried with OutputDebugString. It's not calling the WM_TIMER at all.
I made the nPos global. But still could'nt get it work.
Is it because of USER msg?? I see 2 bars every time ( but npos is not local)
I think that its because of the PBM_SETPOS I do before calling the SetTimer().
I tried calling the SetTimer code in INIT (just to check). In that case the WM_TIMER get posted only once. I see 4 bars in the progress bar.
|
|
|
|
|
I found out why...
My WM_USER takes long time to complete. So in that time I thought of displaying the progress bar. But the WM_TIMER is not getting posted until the WM_USER is finished. I was killing the timer at the end of WM_USER. so it seemed like the progress bar is not working. When I commented the kill timer code I see the progress bar getting started after the WM_USER is completed ( which I dont want).
Too bad to use WM_TIMER.
Any way...Thanks for your help.
|
|
|
|
|
It seems like your WM_USER or whatever message processing should be doing work from a separate thread, then your UI can be updating with a progress bar.
|
|
|
|
|
Ann66 wrote:
The execution is not calling WM_TIMER at all.
What does the call to SetTimer() look like? Where is it called from?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Search for all KillTimer calls. Something could be killing it.
No see-you, no heal-you. Ptthh.;P - Der Dokter
|
|
|
|
|
I am trying to convert a DLL into a static library . This DLL is a MFC DLL and uses a CWnd Object .
I was able to modify the project to create a .lib file . The problem is run -time where the Cwnd object is being created inside the static library . Keep getting an assertion
::AfxRegisterWndClass( NULL);
AfxGetInstanceHandle()
CMyWnd::CMyWnd()
I also use CAsyncSocket in the static library . This call also fails throwing the same assertion .
Any suggestions ?
Engineering is the effort !
|
|
|
|
|
Here's the class:
class MyClass<br />
{<br />
public:<br />
MyClass();
int MyMethod(int MyVariable);<br />
};
Now, this code is valid, that's for sure:
int i = 5;<br />
MyClass MyObject;<br />
MyObject.MyMethod(i);
But can I use this class without declaring an object? Like:
int i = 5;<br />
MyClass().MyMethod(i); // is this right?
|
|
|
|
|
I'm not certain it is a valid C++ syntax, maybe in some recent implementation ?.
but I can bet that it will generate the same kind of assembly code.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
acidtechno wrote:
But can I use this class without declaring an object? Like:
Yes, you can.
you only should declare that MyMethod is a static member function.
Just like that:
<br />
class MyClass<br />
{<br />
public:<br />
MyClass();
static int MyMethod(int MyVariable);<br />
};<br />
|
|
|
|
|
That would not be the same thing.
a static method cannot access member variable.
he wants to simply not have to declare the variable, and take a shortcut.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Firstly does the code compile?
If not, it does not work,
if yes, It might work, ( i have not tested it)
the object will be created, method will be called and distroyed immediatly,
So you cant maintain any state for that object. So initialising the members of the class for future makes no sence.
so it is as good as calling a function called MyMethod which does some processing.
-prakash
-- modified at 23:15 Tuesday 11th October, 2005
|
|
|
|
|
Hello,
Your code is right. The C++ standard allows the modification of temporary objects.
What you do is create a temporary object on the stack (MyClass() creates the temporary). Second you call the MyMethor() function on the temporary. After the statement, the temporary is destroyed and you achieved nothing. In short, your object will be gone after the statement and will be useless. Maybe the compiler even removes the statement..
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I see the light ... thanks for the explanation.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
You're welcome
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Well, actually I wrote this code and it works. The only thing I want is to get a return value of function MyMethod() and if I use for example:
int i = 5;<br />
int MyValue = MyClass().MyMethod(i);
the MyValue variable actually has got the value returned by function MyMethod(). So, I don't actually care in this case if that temporary object is destroyed as long as I can get the return value of it's function MyMethod().
By the way, I use Visual Studio .NET 2003 and I've noticed something strange about this:
class MyClass<br />
{<br />
public:<br />
MyClass();
MyClass(CString MyString);
int MyMethod(int MyVariable);<br />
};
I use this temporary object by calling a constructor with parameter, like:
CString MyString;<br />
MyString = "Example string";<br />
<br />
MyClass(MyString). <- at this moment I do nothing, and the list of variables and methods appears
But if I use a default constructor (with no parameters), like:
MyClass(). <- there's no list, although it should appear
I've noticed that the list of variables and methods appears when the code is ok, but if I have mistakes in the code, it doesn't appear. So if the list doesn't appear after calling a constructor without parameter, and if it appears after calling a constructor WITH parameter - something is not quite ok...
Thanks for replies.
|
|
|
|
|
Hi !
I need to replace some fields in the http header in all (http) traffic passing through my PC. I decided to do it via LSP.
The header I want to edit is in the WSPSend function of my LSP.
Here is the func declaration :
int WSPAPI WSPSend (
SOCKET s,
LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesSent,
DWORD dwFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, LPWSATHREADID lpThreadId, LPINT lpErrno )
The data I want to edit is in lpBuffers. The trick is that I don't know how many buffers (dwBufferCount) there can be and who is setting this value. In most cases it's set to 1. It means that we write lpBuffers[0].buf to get to the needed buffer.
When I try JUST to replace let's say the address in HOST field of the http header to the address with the same quantity of letters, then it's OK. Now, let I want to replace the address from 'www.yahoo.com' to 'www.microsoft.com', what should I do ? First I thought I have to free the old buffer (lpBuffers[0].buf) and set to new one, but when I do so, my IE crashes. So maybe I have to alloc new buffer and set its address to lpBuffers[1].buf and its length to lpBuffers[1].len ? Then who will free it ? Do I have to do that or the system ? If this is fault way to solve my task, then how can I do it all ?
-- modified at 18:37 Tuesday 11th October, 2005
|
|
|
|
|
Hello,
I want to paint text to a window usint CDC::PaintText or CDC::TextOut. The problem is, when I do this, the text is being painted in some ugly bold font. I just want to use the default Windows font.
So, how do I specify what font I want to use when using the CDC methods?
Or, how do I prevent the selection of the bad font I'm getting?
Thanks!
-Ian
|
|
|
|
|