|
Hi,
if i open a CDialog in a thread, which is destroyed after the execution-block, the debugger
alers that the memory of the variable (of the dialog) is corrupt.
Are windows always created in another thread as the current?
Normally, i create the object in a thread, which is in the thread-allocated-memory and all
operations are done in the "thread-memory".
Is it different for windows, probably because of the messageloops and other window-related-objects?
Thanks
PS: So i need to send a message to my general thread which opens the dialog-window?
|
|
|
|
|
I do so sometimes and it works. Actually, no strange thing in this, sometimes we have to do smth like openning a dlg in a thread. But beware, you should be careful in interthread communications. If your code crashes, abviously smth goes wrong in the code; is the dlg in the heap or stack or how do you destroy it?
--
======
Arman
|
|
|
|
|
thanks for your reply
i create a base-thread-class which is derived from a CWinThread.
Then i set a String-variable to the specially value of the task f.ex. "ListCustomers"
After this i post a message to the thread an there'in he checks the variable and starts
in deppension of the value the correct function ( which realises the task )
After the task is done, the thread post a message to the window and says "I'm ready"
That's the background of my thread-structure...
In a specific task i need to open a DialogBox, like this :
DOptions dlg(NULL,"showInfo");
dlg.DoModal();
at the end of the function, dlg will be killed, there the error-message appears.
|
|
|
|
|
baerten wrote: at the end of the function, dlg will be killed, there the error-message appears.
Are you freeing something in the destructor of the dialog class. If so is the pointer valid.
baerten wrote: After this i post a message to the thread an there'in he checks the variable and starts
in deppension of the value the correct function ( which realises the task )
After the task is done, the thread post a message to the window and says "I'm ready"
You should use AfxBeginThread to start off a thread. If you want it not to start the use CREATE_SUSPENDED option. Then later when you want it started call ResumeThread .
|
|
|
|
|
I'm learning mfc recent now. And I get a word quit confuses me , "hook"! it appears it the "chapter Window Messaging" of " programming applications for windows 4th edition"
quotion below:"
Let's start off with some ground rules. Windows allows a single process to create up to 10,000 different types of User objects: icons, cursors, window classes, menus, accelerator tables, and more. When a thread calls a function that creates one of these objects, the object is owned by the thread's process. So, if the process terminates without a thread explicitly destroying the object, the operating system will automatically destroy the object. However, two User objects—windows and hooks—are owned by the thread that creates the window or installs the hook. So, if a thread creates a window or installs a hook and then that thread terminates, the operating system automatically destroys the window or uninstalls the hook.
"
what does "hooks" meaning ? thanks!
kevien
|
|
|
|
|
Hooking in this sense means getting notification of specific window (creation, initialization, etc.) and being able to get access to (or intefere with) with the data associated with that event as well as being able to do additional processing.
Look up the hook-related functions like SetWindowsHookEx(...) for more details. MSDN also had documentation on "Windows Hooks" that wil be useful to you.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi
All
I am creating owner drawn menu(without using resource editor) so i want to know how to set ID to menu item.
With Regards
Atool
|
|
|
|
|
|
I have create one dll in VC++(win 32 dll) .I want to use the function of that dll in another dll in VC++(win32 dll).
how to do this..
Pls.help me
|
|
|
|
|
Try using LoadLibrary, GetProcAddress and FreeLibrary
Regards,
Paresh.
|
|
|
|
|
induvijay wrote: I have create one dll in VC++(win 32 dll) .I want to use the function of that dll in another dll in VC++(win32 dll).
how to do this..
This[^] should help.
|
|
|
|
|
|
|
just wondering, why are you exposing your DllMain() function in your .def file ?
AFAIK, no one should call it explicitely (the system does it) so there's no need for any one to see its clear name (even the mangled name is not shown in normal cases i believe)
|
|
|
|
|
Thanks for ur suggestions.I can link the dll.
one more query how to get the function protype of
or system dll.how to access them.
pls help me.
|
|
|
|
|
Hi All,
How do i determine whether my application window has the focus or not?
Sunil
|
|
|
|
|
Try using CWnd::GetFocus .
Regards,
Paresh.
|
|
|
|
|
sunilpv1982 wrote: How do i determine whether my application window has the focus or not?
Use GetFocus() which returns the CWnd* object which currently has focus...
So you can compare likewise...
bool <code>CYourMainWindow</code>::IsFocussed()
{
return GetFocus()->GetSafeHwnd() == this->GetSafeHwnd();
}
|
|
|
|
|
GetFocus() returns a HWND. I am not sure about this???
Sunil
|
|
|
|
|
sunilpv1982 wrote: GetFocus() returns a HWND. I am not sure about this???
MFC version of GetFocus() return CWnd* .
|
|
|
|
|
Don't compare CWnd* values to tell if they are the same window. Call GetSafeHwnd() on both and compare the HWND s.
|
|
|
|
|
Michael Dunn wrote: Don't compare CWnd* values to tell if they are the same window.
Yes you are right and dang! what was I thinking. I should compare HWND's. Thanks Michael.
|
|
|
|
|
Hello All,
I have just build my windows app. to send a specific https request. At runtime it shows error code 12002 which is related to the request timeout I think.
When I saw the debug output, it shows like this :
'SSLConnection.exe': Loaded 'E:\ProgramFiles2\Microsoft Visual Studio\myprojects\SSLConnectionold\Debug\SSLConnection.exe', Symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\wininet.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\crypt32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\msasn1.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\wsock32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\userenv.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\wintrust.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\schannel.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\rasapi32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\rasman.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\tapi32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\rtutils.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\msv1_0.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\iphlpapi.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\sensapi.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\mswsock.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\rasadhlp.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\dnsapi.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\winrnr.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\pnrpnsp.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\urlmon.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\hnetcfg.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\wship6.dll', No symbols loaded.
'SSLConnection.exe': Loaded 'C:\WINDOWS\system32\wshtcpip.dll', No symbols loaded.
The thread 'Win32 Thread' (0xb60) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x7b0) has exited with code 0 (0x0).
The program '[260] SSLConnection.exe: Native' has exited with code 0 (0x0).
Can anyone tell me how to come out of this ?
Thanks for your prompt reply.
Nikhs
Nikhil Trivedi
|
|
|
|
|
As far as i can see, all is well. No problems what so ever.
If you would like to see what happens inside your program, run your program in debug mode.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hi all,
I want to know whether a function exists that can invoke a messagebox with a editbox inside of it (From a WIN32 console application / without using MFC)??
Makes sense ?
Thanks
Regards,
-- modified at 8:52 Tuesday 17th April, 2007
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|