|
Hi,Rahim:
Your code run very well in my class, thx!
now i met some problem when it's running in a thread,
<br />
DWORD WINAPI CallOut(LPVOID lp)<br />
{<br />
...<br />
CMainFrame* pMainFrmWnd = (CMainFrame*)AfxGetMainWnd();<br />
ASSERT(pMainFrmWnd != NULL);<br />
CvcydcjView* pYourView = NULL;<br />
CWnd* pchildWnd = pMainFrmWnd->GetWindow(GW_CHILD);<br />
ASSERT(pchildWnd->GetSafeHwnd() != NULL);<br />
while(pchildWnd->GetSafeHwnd() != NULL)<br />
{<br />
ASSERT(pchildWnd->GetSafeHwnd() != NULL);<br />
if(pchildWnd->GetRuntimeClass()->m_lpszClassName == "CvcydcjView")<br />
{<br />
pYourView = (CvcydcjView*)pchildWnd;<br />
break;<br />
}<br />
pchildWnd = pchildWnd->GetWindow(GW_HWNDNEXT);<br />
}<br />
ASSERT(pYourView != NULL);<br />
}<br />
when i debug, the program stopped at:
<br />
while(pchildWnd->GetSafeHwnd() != NULL);<br />
i create the thread using following code:
<br />
m_hCallthread = CreateThread(<br />
NULL,
NULL,
CallOut,
NULL,
0,
NULL
);<br />
can u give me some suggestions? Thx!
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
What were the values in PMainFrmWnd and pChildWnd when the program broke up.
Also tell me the how many times the while loop had processed when this problem came.
Was it a ASSERTION or an unhandled exception.
Also paste the stack trace.
Rahim Rattani
Software Engineer,
Matrix Systems (Pvt) Ltd.,
Karachi - Pakistan
|
|
|
|
|
Rahim Rattani wrote:
PMainFrmWnd
:0x00461300
at first is 0x00462d90
Rahim Rattani wrote:
pChildWnd when the program broke up.
is 0x00000000
Rahim Rattani wrote:
how many times the while loop had processed when this problem came
: it's 2
Rahim Rattani wrote:
Was it a ASSERTION or an unhandled exception.
yes, it's
<br />
ASSERT(pYourView != NULL);<br />
the programme can't run into
<br />
pYourView = (CvcydcjView*)pchildWnd;<br />
Rahim Rattani wrote:
stack trace.
i'm so sorry i don't know how to get it...
Thank you soooooooooooo much!
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
I dont have a clue whats the problem. But still I woudl suggest that instead of obtaning a pointer to the view in a thread and working on it. You should obtain a pointer to it before initiating the thread and pass it to the thread as a parameter. I will consider it as a much better option.
Rahim Rattani
Software Engineer,
Matrix Systems (Pvt) Ltd.,
Karachi - Pakistan
|
|
|
|
|
Thxs! a million,Rahim. You're so kind! so i'd love to ask you another question, your solutions are always Great!!
Rahim Rattani wrote:
before initiating the thread
i think maybe there will be some diffiulties,we initialize the thread in view class. but that's ok, i think now we can use the control using your getitem method, so coooooooool!
now i got another question,wish you can take a look:
i want to use message method, but i don't have a very clear idea about how to use it. here is the circumstance:
there is a process running in my CvcydcjView:
<br />
int CvcydcjView::ReadRecord()<br />
{<br />
OpenDatabase();<br />
CopytoMemory();<br />
SendMessages();<br />
}<br />
<br />
DWORD WINAPI CallOut(LPVOID lp);<br />
{<br />
if(ReceiveMessageFromReadRecord)<br />
DoSomething();<br />
else<br />
Wait();<br />
}<br />
i don't know how to write the code, if you can help, that will be very Great!!!!!!!! Thanks in advance!!!!!!!!!!!
Best Wishes,
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
Rahim Rattani wrote:
The below is the public function
CWnd* CvcydcjView::getItem(UINT p_nResourceID)
{
return GetDlgItem(p_nResourceID);
}
Hi,Dear Rahim:
<br />
pYourView = (CvcydcjView*)pchildWnd;<br />
then i can get pYourView rightly
- - - - - - - - - - - - - - - - - - - - - - - - - -
Many nights we prayed with no proof anyone could hear, we were moving moutains long before we knew we could !
Yet now i'm standing here, although we know there's much to fear, hope seems like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill !
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
Can't you pass the control's pointer to the other class?
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
This is a really bad idea. It means the other class has knowledge about the details of the implementation of the representation, which is none of its business. This violates basic principles of object oriented programming, data abstraction, etc. Even the idea that it is a list control should be a secret from all other classes.
|
|
|
|
|
Anyone have any idea why when I call PostMessage in a callback function, it works just fine on W2K and WinXP, but doesn't work on Win98SE?
On all of the above O/S's, it makes it to the callback just fine, and the PostMessage() succeeds, but on Win98, it never makes it to function which handles the message.
Any ideas? Thanks!
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Are you sure the HWND you are posting to is valid and correct. Have you tried running Spy++ to see if the posted message is being received by the window in question. You might just be lucky that it is working on XP etc.
You didn't mention what the callback is (yours / windows) but that shouldn't make any difference, unless there is some specific Windows Callback where PostMessage can't be used, but I doubt it.
I've never encountered a problem where PostMessage() didn't do what I expected and I use it quite a bit.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Hi Neville - Well, I've been able to use Spy++ on XP to see that the HWND is indeed correct and the CWnd derived class that I'm posting to is indeed receiving the message (WM_USER + 1).
On Win98, i've been able to verify that PostMessage is posting to the correct HWND, however, I can't verify that the CWnd derived class is receiving the message, because I can't get spy++ to run on Windows 98! Any ideas how to do that? Or do you know of a different tool I can use to check that?
By the way, the callback is waveOutProc, which should have no problem using PostMessage within the callback.
Thanks for the help!
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Hi Marcus,
I haven't used W98 in some time but don't recall having problems running Spy++. You could try Winspector Spy http://www.windows-spy.com/[^]
You could add a PreTranslateMessage() into the target CWnd then in that look for your WM_USER+1. Also not that WM_USER messages aren't recommended and instead you should use WM_APP. See the article http://www.codeproject.com/dialog/messagemgmt.asp[^]
If the callback isn't in the main app thread you shouldn't be using CWnd*'s. Post a reply if you need more info on this or look for more J. Newcomer articles on threads.
Hope that helps.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Thanks very much! - I wasn't aware of the WM_USER thing. After changing it to WM_APP, everything is working fine!
Thanks again for the help, and thanks for the links!!
Marcus Spitzmiller
"Why must life be so hard? Why must I fail at every attempt at masonry?" - Homer
|
|
|
|
|
Happy to be of help. You can have the rest of the year off now.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Halo... I was a java user and I have program a application tat allow me to see my node moving when I move around in my house using my mobile phone. now I wan to change the langauge to C++ MFC so as to put on my PDA. And I have successfully coded the stuff. but my node don't move when I on the application. but when I click on the pda I can actually move... meaning my codeds have no problem but the screen can not refresh to paint the new node position. do anyone have a alike application lik mine? or do anyone know wat was the problem y the pda nv repaint. does the WM_PAINT auto repaint all the time?
or U have any question pls ask thank U...
|
|
|
|
|
Adrian Soon wrote:
does the WM_PAINT auto repaint all the time?
No, you have to tell it to redraw. Call CWnd::RedrawWindow() to force the window to redraw.
"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!
|
|
|
|
|
about the stuff... do u have any sample code to share?
thanks for the help...
btw... if I wan to change it from painting to using active X to do it... is it possible?
I need a sample code tat is simmilar to mine... do U know any?
I jus need something tat allow a node to repaint itself without user touching the screen... and the node will move from it spot too...
|
|
|
|
|
Im having probs programming a traceroute program using visual C++...i wonder if anyone is willing to help me with the codes..thank you...
|
|
|
|
|
OK, so I hook this function with a global hook like I would any other and I test it out with a program I made some time ago a client-server app that I knew used this function and it worked like a charm. All it had to d owas show me in a message box what was in the socket.
But then I tryed it with two bulk mailing programs that I had and it crashed both of them.
then I tryed it with outlook express and it didnt' say nothing.
What is wrong?
Why does the hook only work some of the time?
Also I found on a delphi programming site(I hate Delphi) the source of a program that attempted to do just what I was doing, but instead of using a system whide hook they somehow injected the dll into the virtual memory of Outlook and then the dll also made a hook but I don't know if it was global or not cause I don't have the source to their hooking object cause they are selling the source and I don't know Delphi that good either.
What I don't understand is how they expect to actually get the dll to work because they don't seem to be calling any function from it just loading the dll with LoadLibraryA.
I took a shot at translating the code to C and here it is but when I try this method that they(on the site) say works I get nothing(of course I am doing it in C as I don't have a Delphi compiler and with my own hooking class since they won't give me theirs)
void InjectLib(HANDLE hProcess, char *szLibPath)
{
//Vars
char szDLLPath[256];
LPVOID lpBuffer;
HANDLE hThread;
DWORD dwBytesWritten, dwThreadID;
LPTHREAD_START_ROUTINE lpModule;
strcpy(szDLLPath, szLibPath);
//Get LoadLibraryA
lpModule = (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("KERNEL32.DLL"), "LoadLibraryA");
//The Magic Happens Here!
lpBuffer = VirtualAllocEx(hProcess, NULL, sizeof(szDLLPath), MEM_COMMIT, PAGE_READWRITE);
WriteProcessMemory(hProcess, lpBuffer, szDLLPath, sizeof(szDLLPath), &dwBytesWritten);
hThread = CreateRemoteThread(hProcess, NULL, 0, lpModule, lpBuffer, 0, &dwThreadID);
WaitForSingleObject(hThread, 1000); //INFINITE
VirtualFreeEx(hProcess, lpBuffer, 0, MEM_RELEASE);
//The DLL Is Now Injected, Yay!
//Close Handles
CloseHandle(hThread);
CloseHandle(hProcess);
}
|
|
|
|
|
This Article will help you to load the Dll in Memory space of other Application
http://www.codeproject.com/threads/winspy.asp
"I Think this Will Help"
Alok Gupta visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
We need to acquire some research data in Europe with our software and then get the data sent over here (East coast US) for analysis. We tested to run the acquistion on a laptop with the time zone set to the place in Europe, but when burned/copied the data to a local-time-zone win2k machine, the time stamp got changed to the local time based on the difference of time zones. Since we want to keep the europe timestamp (or at lease being able to figure out that), I wonder how the time stamp info is stored in the file. Is there any existing function to simply get the local time of the file creation? I searched this forum and found the function SystemTimeToTzSpecificLocalTime(), but that would require us to tell the software that the data was acquired in a specific time zone, it would be the best if that time zone can be read out from the file directly.
An interesting note, when we copied the burned file to a winnt machine, the time stamp was kept; when we copied the data from the winnt machine back to win2k, the time stamp was still kept, instead of getting swtiched based on local time zone. So somehow, the time zone info was lost when the file was copied to Winnt. Any explanations on this?
Thanks a lot.
|
|
|
|
|
About what kind of partitions are you talking? FAT or NTFS.
Wout Louwers
|
|
|
|
|
NTFS.
And the CD used CDFS.
|
|
|
|
|
Hello,
I encountered a strange error when using the following code to rename tables in an Access database using DAO
BOOL CTableDlg::RenameTable(CString strOldName, CString strNewName)
{
UpdateData(TRUE);
OpenDatabase();
CString sqlCmd;
sqlCmd.Format("RENAME TABLE %s TO %s;", strOldName, strNewName);
db.Execute(sqlCmd);
CloseDatabase();
UpdateData(FALSE);
return TRUE;
}
The error I get is: "The Microsoft Jet database engine cannot find the input table or query 'RENAME TABLE table_old TO table_new;'. Make sure it exists and that its name is spelled correctly."
The table name is correct and a table named "table_old" exists so what am I doing wrong?
|
|
|
|
|