|
I have developed a CListBox based control that overrides, PreSubClass() and OnDestroy(). In PreSubCLass a worker thread is created to query a database for the data to put into the control. The deadlock occurs when the user closes the dialog and the worker thread is still running. I over rode OnDestroy() to signal the thread to terminate and then WaitForSingleObject() to get signalled that the thread has terminated. I am using events to handle this synchronization. Unfortunately the threads deadlock as the UI thread is processing a window message, OnDestroy() and the worker is trying to call AddString which in turn calls ::SendMessage() which now blocks the worker thread. I've tried using a PostMessage call instead and that seemed to solve the deadlock issue. Unfortunately, it also had the side effect that the strings added to the list box never get displayed until the worker thread is complete. Incidently the worker thread checks for the signalled event to terminate within the while loop that is processing all the data returned from the database. Everything works fine, except when the dialog is closed while the worker thread is still running. Any ideas from some more experienced folk? Thanks.
Chris
|
|
|
|
|
Hello, the codegurus around the world.;) (Copy Right 2001 Masaaki Onishi)
We can use the following function to catch the message of "CLOSE".
LRESULT CMyDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CLOSE)
return CDialog::WindowProc(message, wParam, lParam);
}
So, if the user tries to close the dailog even though thread is still running,
the message box shows to say that you can't close this since thread is still running.
However, since we can't take a look at this kind of message in Microsoft product,
you may put some code to make the thread clean in WindowProc
But, it may be tough since while the message is in process, it may be conflict if
we deal with the different message.
Hum, but only closing the application is a problem, so you don't care about the other message?
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
if i have made multiple dialog boxes and i want to link them , how do i do it ? i mean one screen asks for a user id and password, and if i enter them and press OK i show be directed to the next dialog box. Any suggestions ?
<--- this is me
|
|
|
|
|
Hello, the codegurus around the world.;) (Copy Right Masaaki Onishi)
So, CPropertySheet exists.
We use two classes like CPropertySheet or CTabCtrl.
We can use each one to create PropertySheet.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
I believe property sheets have a DoWizard function either in them, or documented in the MSDN, that allows you to run a wizard style dialog easily.
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
I am developing an app that will calculate 2-D arrays of numbers. Of course, the real question is how to format the data in a way that makes sense.
I saw the article on the 2D Data Visualization Class. This is the sort of what I'm looking for. Although, I may want to view the raw data and the graphed data in seperate views.
I also have seen the Excel automation example on MSDN. I want to avoid being dependent on another app being present.
What are the favorite tools out there? My needs are simple so I don't need a tool that costs thousands. I would be perfectly happy with a freebie as long as it was documented well with good examples.
Thanks!
Keith Ramey
|
|
|
|
|
Check out this article (at a competiting site):
http://www.codeguru.com/controls/graph2d.shtml
You may find it interesting. There are some others under
http://www.codeguru.com/controls/index.shtml
George
WillCodeForMoney
|
|
|
|
|
Is this impossible ?
I have tried forever and looked for sample code but i lead me to nothing. The client are is whiter as ever before and no bitmap where ever shown.
BTW it's really sad that the windowsx.h SelectBitmap does not work.
Regards
Andla
|
|
|
|
|
My first thought if putting a bitmap in using the dialog editor does not work would be to use LoadImage if it's a bitmap and draw it myself. GDI+ also has much better support for loading images of different formats ( I'll be posting some tutorials this weekend ).
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Thanks!
I asked experts-exchange also and proved me wrong on the windows.x . I can compile it now. And i can view a bitmap in the client area. Hopefully i will find out why i could not display a bitmap when using a win32 code.
Well it's hard to program something when there is almost no documentation on WTL.
Hopefully Microsoft will support it and forget all the talk about putting it away.
Regards
Andla
|
|
|
|
|
What are the special characters for identifying the end of a line, carriage return and end of fiel when reading a text file?
or is there any?
|
|
|
|
|
end of line will have some combination of cr & lf (\r & \n) depending on the operating system / editor that generated them
end of file ... hmmmmm ... not really ... get the file size before loading it and set the last + char pos to zero manually
or use the CFile classes of course
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
Use istream functions getline and eof.
|
|
|
|
|
Hi,
I have a dialog box that I don't want users to be able to move. Currently I have timer running that centers the window ever 5 milliseconds, which could prove to be a bit heavy on resources so I don't want to continue this way.
My application is a Windows CE app and I want the window to be positioned in one place and never moved.
Any ideas???
Thanks,
Claire
|
|
|
|
|
I am not sure if there is a way to fix the position of the dialog box. Instead of centering every 5 milli seconds, you could check if the position of the dialog box has been changed. If so, you could then reposition.
Siva
|
|
|
|
|
I am not sure but I think you can intercept OnMove event and force to 0 cx and cy.
|
|
|
|
|
Hello, the codegurus around the world.;) (Copy Right 2001 Masaaki Onishi)
Check here by Paul DiLascia.
I think that this works for Dialog application.
http://msdn.microsoft.com/msdnmag/issues/01/02/c/c0102.asp
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
detect WM_MOVING. You might be able to prevent movement by resetting the drag rectangle to the initial dialog position
P.S. - Why don't you want the dialog moved?
|
|
|
|
|
try this:
1:Add the following in the *.h:
afx_msg UINT OnNcHitTest(CPoint point);
2:Add in the *.cpp
ON_WM_NCHITTEST()
3:Add in the *.cpp:
UINT CYourDialog::OnNcHitTest(Cpoint point)
{
UINT nHitTest=CDialog::OnNcHitTest(point);
return (nHitTest==HTCAPTION)?HTCLIENT:nHitTest;
}
good luck for you!
julia
|
|
|
|
|
CMenu *pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
pSysMenu->RemoveMenu(SC_MOVE, MF_BYCOMMAND);
|
|
|
|
|
How I can get the names of regular buttons? (OK, Apply...) - English
In russian language it is simular with: Da, Primenit'
|
|
|
|
|
Help please
I have a structure that uses CTime date
I am using the date picker to select the date
how can i move the data from the date picker to the CTime variable.
|
|
|
|
|
Use CDateTimeCtrl::GetTime method. One of the overloads uses CTime.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Am Working on a NT Service that spawns a thread for each request. The multithreading issues have been taken care of i.e. EnterCriticalSection and LeaveCriticalSection has been added to make the code thread safe. This Service works perfectly fine on a Single-Processor machine but it crashes on a Multi-Processor Machine.
What do I do to make the service Multi-Processor Safe.
Any help will be Appreciated.
Thanks in Advance
Regards
Imtiyaz Shaikh
|
|
|
|
|
Never done it myself but I THINK you want to take a look at spinlocks.
Matt Philmon
|
|
|
|