|
wsprintf(szBuffer, _T("SELECT Controller_Name FROM T_controller WHERE Port_ID='%s'"), str);
|
|
|
|
|
I agree with tocct why you dont use of CString::Format
|
|
|
|
|
Regardless of whether CString::Format() or sprintf() is used, it has to be used correctly. Simply shoving MFC at the problem is not an automatic fix.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi DavidCrow,
how are you
Generaly I dont use from wsprintf because:
From the MSDN
"Security Alert Using this function incorrectly can compromise the security of your application"
|
|
|
|
|
Hi,
call to "COleDateTime::GetCurrentTime()" get crashed in my MFC aplication.
I am using Windows XP, SP2.
Development environment is Visual Studio 6 with Platform SDK for XP SP2.
Thanx in advance.
|
|
|
|
|
The following information is always helpful when diagnosing a crash:
- The type of exception generated.
- The machine code around the faulting instruction.
- The call stack to the faulting instruction.
- The source code around the faulting instruction.
Steve
|
|
|
|
|
I second stephen on this.
Give some code.
|
|
|
|
|
VCSharp007 wrote: "COleDateTime::GetCurrentTime()" get crashed in my MFC aplication
COleDateTime::GetCurrentTime() has an issue since it uses the underlying time_t type for returning time. Now when year 2038 jan happens time_t reaches it's limit hence wraps around.
Instead of COleDateTime::GetCurrentTime() try using GetLocalTime . GetLocalTime returns local system time based on your timezone.
This is could be the problem.
More info[^]
|
|
|
|
|
Nibu babu thomas wrote: This is could be the problem.
How, since we are roughly 32 years away?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: How, since we are roughly 32 years away?
Yeah true. But our client tested our product with year greater than 2038 to see if such issues are handled properly. Hence I thought this could be the problem, since our application crashed when it was tested like this.
|
|
|
|
|
Nibu babu thomas wrote: COleDateTime::GetCurrentTime() has an issue since it uses the underlying time_t...
Actually it uses a DATE , which is a double . CTime has the year 2038 problem.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hi,
Ensure that COleDateTime::GetCurrentTime() is not assigned directly to other variable than COleDateTime class type.
Try if this will throw an exception:
COleDateTime dateTime = COleDateTime::GetCurrentTime();
Best regards
|
|
|
|
|
Hi,
What is the VC++ Substitute for the MFC <code>SetIcon</code> function??
Thanx in Advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I think you should look at DrawIcon() /LoadIcon()
SetClassLong(): Your application can replace a class icon by using the SetClassLong function.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Use the WM_SETICON message.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
For a static control, send it a STM_SETICON message. For a button, send it a BM_SETIMAGE message. For all others, send them a WM_SETICON message.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all,
How would I go about getting hold of the handle to the instance of the application.
<code>
HINSTANCE hInst
</code>
I know in MFC one would use <code>AfxGetInstanceHandle()</code> ,so what can I use in good old VC++?
Thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
what about first parameter of Winmain ? .
From MSDN;
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
);
|
|
|
|
|
Thanx for the response. The other question I have is:
<pre?
in mfc="" one="" would="" use="" <code="">SetIcon</code> to set the Icon, what can I use for VC++, <code>LoadIcon</code> ???
Thanx Again
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Here another way. The function GetHandleToModuleWhichContainsThisFunction returns the HMODULE of the module that contains it. It's better to use the value passed in WinMain but this technique come in handy from time to time.
#include <iostream>
#include <windows.h>
namespace
{
HMODULE GetHandleToModuleWhichContainsThisFunction()
{
HMODULE hMod = NULL;
const void *pFunc = &GetHandleToModuleWhichContainsThisFunction;
MEMORY_BASIC_INFORMATION mbi;
if ( VirtualQuery(pFunc, &mbi, sizeof(mbi)) == sizeof(mbi) )
{
hMod = reinterpret_cast<HMODULE>(mbi.AllocationBase);
}
return hMod;
}
HMODULE GetHandleToInstanceWhichContainsThisFunction()
{
return reinterpret_cast<HINSTANCE>(GetHandleToModuleWhichContainsThisFunction());
}
}
int main()
{
HMODULE hMod = GetHandleToModuleWhichContainsThisFunction();
using namespace std;
char Path[MAX_PATH];
GetModuleFileName(hMod, Path, sizeof(Path)/sizeof(Path[0]));
cout << Path << endl;
return 0;
}
Steve
|
|
|
|
|
Thanx Steve, I'll chech it out...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Hi,
I am working in a project where I need to position my applications icon on active/Foreground window. It works well in all cases except when user right clicks on a icon in task bar system tray it get positioned to wrong place. When I debugged into code I found that the GetWindowRect function itself gives wrong values(like 0,0,123,34) for context menus. How can I solve this problem? Why GetWindowRect fails?
Regards,
Hemant Kulkarni.
|
|
|
|
|
Can you post some code?
Steve
|
|
|
|
|
Here is some part of my code
// get the desktop window
// we assume the desktop window is never null and never iconized
IntPtr DTwnd = User32.GetDesktopWindow();
// taskbar window
IntPtr TaskBarhwnd = GetTaskbarWindow();
//initialize the window handle to null(zero)
IntPtr hwnd = DTwnd;
//get foreground window
IntPtr FGhwnd = User32.GetForegroundWindow();
// my current location
Point CurrentLocation = new Point(this.Location.X,this.Location.Y);
// set the new FG window as holder window
hwnd = FGhwnd;
User32.RECT windowRect = new User32.RECT();
// get foreground/desktop window location
User32.GetWindowRect(hwnd,ref windowRect);
Regards,
Hemant.
|
|
|
|