|
It is not a question of "one is better than the other".
you MUST use _T() with TCHAR and L with WCHAR.
the point that UNICODE is defined is not for "WM" at all. it is defined in your project settings, and some might want to build a non unicode version.
if your code is well written then, only switching the parameter in the project settings will do. otherwise, you'd have to change every line of code using L to remove it, so that the ANSI build can perform successfully.
so be independant of that, and use _T()
|
|
|
|
|
akirilov wrote: I don't know the difference of TCHAR* xx and TCHAR *XX
xx is a different variable than XX . Whether you put the space before or after is irrelevant, as the compiler sees tokens rather than spaces.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi,
I have an application which executes query through ExecuteSQL statement in an postgres 8.1 windows native version.
During ExecuteSQL if the server is switched off(power off) the system gets hanged and no exception is thrown.
The reason we found out is since the communication happens through TCP/IP and the TCP_KEEPALIVE_IDLE time is 2hrs by default it takes lot of time for sending the next heartbeat request.
It can be reduced by changing the value in registry , but the problem we are facing is since it will be modified for all the TCP/IP ports,it will increase the network traffic.
Is there any way to restrict the option only to a port ? If so how to apply it to the port confiured for the datasource.
Else is there any other ways to solve the issue?
Thanks
Krishnan
|
|
|
|
|
I am using Microsoft visual c++ 6, and I want to draw shapes on a view.
What i want is a displayed shape with a
semi-transparent color i.e. we should still be able to see whatever is
beneath the shape. Can anyone help me?
Thanks.
|
|
|
|
|
You could use GDI+[^]
Gdiplus::Graphics g(hwnd, 0);
Gdiplus::Pen p(Color(64, 255, 0, 0), 10);
g.DrawLine(&p, 0, 0, 400, 400);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you very much for your answer!
It works fine, thanks again!
|
|
|
|
|
|
I have just added this section of code to the initinstance of my app.
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2,2),&wsaData);
if (iResult != NO_ERROR) {
OutputDebugString("Error at WSAStartup()\r\n");
}
just before this line
int nResponse = dlg.DoModal();
when this is run an unhandled exception occurs
the message reads
"Unhandled Exception in MyApp.exe: 0xC0000005: Access Violation"
When I click 'OK' the code breaks at this line
size_type size() const
{return (_First == 0 ? 0 : _Last - _First); }
which is line 114 in the VECTOR.h file from the VC98\include directory.
Anyone have any ideas, I am using VC6.
Cheers
Jim
|
|
|
|
|
Could you please post the entire code snippet of your InitInstance() function? There is no chance for a vector to be in a mfc wizard generated InitInstance() . I think some other code block of your's is causing the problem.
Well, while posting code, please enclose in "code block" so that the it will be easier to read.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
jimjim733 wrote: when this is run an unhandled exception occurs
And if you remove the code, does the error go away?
Yes I realize you need sockets initialized but that is a secondary problem.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Yeap, it goes away.
Here is a copy of the InitInstance
Cheers
Jim
BOOL CMyApp::InitInstance()
{
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2,2),&wsaData);
if (iResult != NO_ERROR) {
OutputDebugString("Error at WSAStartup()\r\n");
}
CMyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
}
|
|
|
|
|
I can't see what's causing the exception, but is
there a reason you're not calling the base class
InitInstance()?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry, not sure I follow....that is the base class of the project....isn't it?
Am I missing something here?
|
|
|
|
|
jimjim733 wrote: that is the base class of the project....isn't it?
Maybe it is (I can't see the header file) but it looks so much like
an MFC CWinApp/CWinAppEx InitInstance() override that I assumed it was
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
ok, so what do I need to do?
|
|
|
|
|
Something like this:
BOOL CMyApp::InitInstance()
{
if (!CWinApp::InitInstance())
return FALSE;
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif
...
Not all base class implementations of virtual functions do anything
but there is a little code in CWinApp::InitInstance() that may or may
not be important.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No, that didn't work
|
|
|
|
|
What does "didn't work" mean?
I didn't expect it to fix the exception - i only pointed
out the fact that it was missing and wondered if there
was a reason.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry, just thought that might have fixed it.
|
|
|
|
|
When the exception is thrown, what does the call stack look like?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
here's a copy of the stack
not sure what I am looking for???
Jim
std::vector<UnitInfoStruct *,std::allocator<UnitInfoStruct *> >::size() line 114 + 15 bytes
CAlinksRemoteControl::ScanForUnits() line 480 + 14 bytes
CMultiVueDlg::OnInitDialog() line 130
AfxDlgProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, unsigned int 3081096) line 35 + 14 bytes
USER32! 7e418734()
USER32! 7e42413c()
USER32! 7e423b30()
USER32! 7e43e599()
USER32! 7e418734()
USER32! 7e418816()
USER32! 7e42a013()
USER32! 7e42a998()
CWnd::DefWindowProcA(unsigned int 272, unsigned int 3081096, long 0) line 1000 + 32 bytes
CWnd::Default() line 249
CDialog::HandleInitDialog(unsigned int 3081096, unsigned int 3081096) line 624 + 8 bytes
CWnd::OnWndMsg(unsigned int 272, unsigned int 3081096, long 0, long * 0x0012f800) line 1815 + 17 bytes
CWnd::WindowProc(unsigned int 272, unsigned int 3081096, long 0) line 1585 + 30 bytes
AfxCallWndProc(CWnd * 0x0012fc08 {CMultiVueDlg hWnd=???}, HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 215 + 26 bytes
AfxWndProc(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 368
AfxWndProcBase(HWND__ * 0x00240334, unsigned int 272, unsigned int 3081096, long 0) line 220 + 21 bytes
USER32! 7e418734()
USER32! 7e418816()
USER32! 7e42927b()
USER32! 7e42651a()
USER32! 7e42683e()
USER32! 7e439b43()
CWnd::CreateDlgIndirect(const DLGTEMPLATE * 0x0042b540, CWnd * 0x00000000 {CWnd hWnd=???}, HINSTANCE__ * 0x00400000) line 327 + 36 bytes
CDialog::DoModal() line 531 + 32 bytes
CMultiVueApp::InitInstance() line 71 + 11 bytes
AfxWinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 39 + 11 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f0c, int 1) line 30
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 7c817067()
|
|
|
|
|
jimjim733 wrote: not sure what I am looking for???
It looks as though your code gets all the way into OnInitDialog() before the exception is thrown.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Like David said, you seem to get as far as to OnInitDialog .
Is it possible that the code using the vector doesn't run if the socket lib hasn't been initialized?
That could explain why the error "goes away" if you omit the call to WSAStartup .
To me it looks like the std::vector<UnitInfoStruct*> vector has not been created properly since vector::size() only operates on internal data and doesn't change anything.
Could it be that the vector variable is a pointer that you haven't allocated memory for?
Just guessing, but it could be worth checking...
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Okay, thanks.....i'll take a look
|
|
|
|
|
okay, can you help?
I am not sure how to do this
Below are the only references I have for UnitInfoStruct
struct UnitInfoStruct *pUnit = NULL;
pUnit = new struct UnitInfoStruct;
vector<struct UnitInfoStruct *> m_vszIPAddr;
struct UnitInfoStruct {
char szIPAddr[16];
char szSer[9];
};
As you can tell, I am struggling with this a bit.
Jim
|
|
|
|