|
Hmmmmm... ok. Does the WM_CLOSE handler for the window actually destroy the window, or does it post a WM_DESTROY message or something similar, ie. Has the window been destroyed in the WM_SETFOCUS handler (use IsWindow() to check the HWND).
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"
|
|
|
|
|
GetSafeHwnd() returns the HWND I am looking for, but IsWindow() returns FALSE. So that tells me the window was destroyed.
What I am now thinking is that the CWnd passed to OnSetFocus is a CTempWnd class, so that would mean that it is just a copy of the CWnd of the CInPlaceEdit class that was destroyed. Being a copy it contains the same m_hWnd value as the original even though the original has already been destroyed and deleted.
It all makes sense to me now. Thanks for the push in the right direction so that I could figure out what was going on
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
What I am now thinking is that the CWnd passed to OnSetFocus is a CTempWnd class, so that would mean that it is just a copy of the CWnd of the CInPlaceEdit class that was destroyed. Being a copy it contains the same m_hWnd value as the original even though the original has already been destroyed and deleted.
AFAIK, That's not quite how CTempWnd works. If the window was an MFC window, and has not been deleted, then you will always get a pointer to the actual window class. If the window has been destroyed (or is not an MFC window), then you'll get a pointer to a CTempWnd. I think what's happening is that Windows is passing the HWND of the destroyed window to the WM_SETFOCUS handler, intending it purely for information, and MFC is creating a CTempWnd object to map it to, because the window has already been destroyed.
PJ Arends wrote:
Thanks for the push in the right direction so that I could figure out what was going on
Glad to be of help At least it's enlightened me as well
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"
|
|
|
|
|
Hi,
I'v got a problem trying to draw on DC of a dialog while using animatewindow(....AW_BLEND)
My drawings does NOT appear until I call Invalidate() manually!
So what happends is that an empty dialog Fades In and then all drawings suddenly appears.
It's so ugly!
However, I found a solution that I did not understand(!):
OnPrint(WPARAM wParam, LPARAM lParam)
{
CDC* pDC = CDC::FromHandle((HDC)wParam);
if ( lParam & PRF_NONCLIENT )
Do some drawings...
return 0;
}
[Author Mr. Shog9] did the following in a window(CWnd)
2 things:
1-It's difficult to understand, why a dialog box may have OnPrint Message[ consider the fact that I'm a beginner ]?!!
2-While Fading out, the code (some times) frozens the application
as Mr. 'richard sancenot' mentiond at the end of that article (Title:Balloon Help as a non-modal replacement for MessageBox())
Could any one Help me please?
Even if there is any article previously, would you tell me please.
I thank you in advanced.
Best regurds, Hamed.M
p.s.Excuse me if my english is not well.
|
|
|
|
|
Hi, my scenario is like this:
I link a dll at run-time by calling LoadLibrary() and then I call GetProcAddress to get the location of a function within that DLL so i can call it. This works fine. But now I wanted to get the location of a variable, and address that, but it doesn't work. In my DLL I have a declaration as follows:
extern "C" { char * szLogFile = "C:\\log.txt"; }
So I try to address the variable from my program as follows:
char * test = (char*)GetProcAddress(hinstDLL, "szLogFile");
But when I then try to show the variable test using a messagebox I just get garbage so the pointer must be wrong.
Any ideas whats wrong?
Kuniva
--------------------------------------------
|
|
|
|
|
I've seen this same problem. I can't recall why now. I suggest you add a set/get function to the DLL and use that to access the variable instead. BTW global variables are evil.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Heh, damn, I was kinda hoping for an explanation, I hate having to have to avoid the problem. But I guess I don't have much choice so thank you for your reply anyway.
And as for the global variables are evil thing, so they keep telling me.. I don't see any reason why they should be evil in very small programs though :P
And generally I believe it to be said by people who can't make sense of their own programs after a while
Also, no stack operations means more speed, weee.
So, in short, global variables are evil, but fun!
lol.. just messing.
Kuniva
--------------------------------------------
|
|
|
|
|
Hi,
If someone has the answer to this I will be most greatful. I cannot get the select() function to work here. My program successfully sends the message and the server responds to this message(I have seen the results on ethereal). What I am trying to accomplish is send out a UDP message(the one defined by RequestStatMsg(which is properly formatted and correct and works fine)), then use the select function as shown below to simply listen for a reply for one second, and log if there is a reply, then repeat. The idea is to test a device to see if it responds to this UDP status request message promptly, and to log failures...testing over long durations(days). This is driving me mad. Thank you for any input you may provide!!
CODE
//Global
typedef struct{
unsigned short MsgID; /* REQUEST_STAT_MSG (0x00) */
unsigned short MsgSize; /* Bytes in this message */
}RequestStatMsg;
SOCKADDR_IN remote; // For client
SOCKET sock; // For client
SOCKADDR_IN RecvAddr; // "server usage on PC side"
SOCKET RecvSocket; // for recieving the Stat request message
struct timeval stTimeOut; // Create the timestruct for the
fd_set stReadFDS; // Set the file descriptors
fd_set stXcptFDS;
.
.
.
// everything else isinside <int cjtf_appdlg::onsend()="">
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
RecvSocket = socket(AF_INET, SOCK_DGRAM,IPPROTO_UDP);
.
.
.
while(true)
{
// the sendto works fine
sendto(sock, (char *)&ReqStatMsg,sizeof(ReqStatMsg),
0,(SOCKADDR *)&remote, sizeof(SOCKADDR));
StatMsgSent++;
TempStr.Format("%d", StatMsgSent);
m_MsgSentCnt.SetWindowText(TempStr);
stTimeOut.tv_sec= 1; // 1 sec timeout
stTimeOut.tv_usec=0; // use for milliseconds
// Bind the socket to RED SIDE and the specified port.
RecvAddr.sin_family = AF_INET;
RecvAddr.sin_port = htons(prt); //
RecvAddr.sin_addr.s_addr = inet_addr(IPAddrStr);
bind(RecvSocket, (SOCKADDR *) &RecvAddr,
sizeof(RecvAddr));
// Prep the members
FD_ZERO(&stReadFDS);
FD_ZERO(&stXcptFDS);
FD_SET(RecvSocket, &stReadFDS);
FD_SET(RecvSocket, &stXcptFDS);
// set up to for 1 second
retvalue = select(0,&stReadFDS, NULL, NULL, &stTimeOut);
// handle the case that no message is available
through(timeout 1sec)
// else receive the message
recvfrom(RecvSocket,RecvBuf,BufLen, 0,(SOCKADDR*)
&SenderAddr, &SenderAddrSize);
// This ALWAYS times out after one second, but I know the response is coming back(ethereal). The server simply responds to the clients ip address and port that it sent from. I'm not getting it though???
Thank you in advance for your help!
Rich
|
|
|
|
|
I am opening and reading from a text file and am trying to figure out the function to get the size of the file.
Windows reports the file as being 33KB, and I want my program to be able to report that as well.
Appreciate the help.
|
|
|
|
|
|
Or lseek() to end of the file or ftell() for the old fashioned streams.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
GetFileSize() comes to mind.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks everyone. GetStatus worked.
|
|
|
|
|
I'm not an MFC guru so plrease don't laugh if my question is stupid.
I've created my project with IE.4 Rebar support. I have created class for rebar dialog (i called it CMessageDialog). Then I drag and drop a push button on the rebar and created the function to handle clicking on it.
The problem is that when i launch my application the button is inactive. Please help.
|
|
|
|
|
Have you added code to Enable the command?
eg.
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
...
ON_UPDATE_COMMAND_UI( ID_KB_TAB_BAR_POS, OnUpdateDocumentTabBarPos )
END_MESSAGE_MAP()
void CMainFrame::OnUpdateDocumentTabBarPos( CCmdUI* pCmdUI )
{
pCmdUI->Enable( TRUE );
}
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
What is ID_KB_TAB_BAR_POS ? I don't have anything like that.
|
|
|
|
|
Replace this with the #define for the ID of the your toolbar button. Likewise change the function name to something appropriate. These were just pulled out of code of mine.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Should it be defined at the CMainFrame class or class of my toolbar dialog? Also in Class Wizzard the are only 2 messages available for my button: BN_CLICKED and BN_DOUBLECLICKED. Thank you in advance.
|
|
|
|
|
It should be in whatever class the code you want to execute upon button press lives. See the various Help topics on ON_UPDATE_COMMAND_UI for more info.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Dear all,
I'm trying to write an ODBC Driver DLL. I register it with
SQLInstallDriverEx and Implement "ConfigDSN" and "SQLConnect". With
"SQLConfigDataSource" i register Some Data source( ds1 ), but if I try to
connect via "SQLConnect" ODBC's "SQLGetDiagRec" return "Driver Doesn't
support this function" !?!?.
I found my DSN ( ds1 )in ODBC Data sources in Control Panel, and when i open
it, ODBC shows an error message "Driver's ConfigDSN : Component not found in
registry". But in registry in "ODBCINST" I have "ConnectFunctions=YNN" which
mean that I support "ConfigDSN" !?!. The same situation after reinstal MDAC.
My DLL's functions work fine if i load dll with "Afx/LoadLibrary".
What is Wrong?
Win2000 SP3, MDAC 2.8
--------------------
Here is my Driver String which i use to register my Odbc driver:
LPCTSTR pszDriver =
_T("MyDriver\0DRIVER=MyDriver.dll\0SETUP=MyDriver.dll\0SQLLevel=1\0FileUsage=0\0DriverODBCVer=01\0ConnectFunctions=YNN\0APILevel=2\0CPTimeout=60\0\0");
SQLInstallDriverEx(pszAttributes ,NULL, szLoc, FILENAME_MAX, &nLocLen,
ODBC_INSTALL_COMPLETE, &nUsageCount );
--------------------
Here is my sample code for Connection
----------------------
rc = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0);
rc = SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc);
rc = SQLConnect(hdbc,(SQLCHAR*) "ds1", SQL_NTS, (SQLCHAR*) "", SQL_NTS,
(SQLCHAR*) "", SQL_NTS);
----------------------
Regards :
KalliMan
a
|
|
|
|
|
I want using VC++ to read/write an object of MyClass from/to a file. I've write
CFile myFile;
...
myFile.Write((char*)&myObject, sizeof(myObject));
So in my file there is a stranger string
How can I do properly?
I'm a beginning of programing.
Please help me!
Best regard!
|
|
|
|
|
Hi,
You cann't write directly class into File. You must use Serialization, and serialize each memeber from your class. See the sample below and look into MSDN for more Info.
class CPerson : public CObject
{
public:
DECLARE_SERIAL( CPerson )
// empty constructor is necessary
CPerson(){};
CString m_name;
WORD m_number;
void Serialize( CArchive& archive );
// rest of class declaration
};
void CPerson::Serialize( CArchive& archive )
{
// call base class function first
// base class is CObject in this case
CObject::Serialize( archive );
// now do the stuff for our specific class
if( archive.IsStoring() )
archive << m_name << m_number;
else
archive >> m_name >> m_number;
}
a
|
|
|
|
|
I've got the error:
error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CStudent::GetRuntimeClass(void)const " (?GetRuntimeClass@CStudent@@UBEPAUCRuntimeClass@@XZ)
Please help!
|
|
|
|
|
|
thanks all!
|
|
|
|
|