|
Thank you heaps
THis is what I am looking for. I have found that not all of this is being put into the 'chunk' by the present server code.
Happy programming!!
|
|
|
|
|
|
Last month I posted a problem about my dialog buttons not responsive. Thanks to reply posted by Christian, that's solved by using a worker thread.
I'm now having a couple of problems after solving the above. Hope someone can advise.
The worker thread is started when the user clicks on the CONVERT button. I then change the Cancel to be the default button, so that a simple Enter
would abort the very lengthy conversion.
void CConvert::OnConvert()
{
// start the worker thread
AfxBeginThread(MyThreadProc,this);
// change the buttons
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(FALSE);
m_ok.EnableWindow(FALSE);
m_cancel.SetButtonStyle(BS_DEFPUSHBUTTON);
m_cancel.SetFocus();
}
// my worker thread
UINT MyThreadProc (LPVOID pParam)
{
CConvert * pObject = (CConvert*)pParam;
pObject->DoConvert();
return 0;
}
// my original code to do all the conversion
BOOL CConvert::DoConvert(void)
{
// lots of code up here not shown
//
if (AbortFlag)
{
// conversion was cancelled. Dialog box is gone.
return FALSE;
}
else
{ // normal completion. Dialog box still visible.
// make the OK button default
m_convert.SetButtonStyle(BS_PUSHBUTTON);
m_convert.EnableWindow(TRUE);
m_cancel.SetButtonStyle(BS_PUSHBUTTON);
m_ok.SetButtonStyle(BS_DEFPUSHBUTTON);
m_ok.EnableWindow(TRUE);
m_ok.SetFocus();
// UpdateData(FALSE); // Cause Assertion Fail. Why?
}
return TRUE;
}
1/ After sucessful conversion the OK button is shown as the Default button, but when I hit Enter, conversion starts again. Seems like the focus is still on the Convert button. How come?
2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?
3/ I think I'm wrong to put all these button manipulations in the worker thread. Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread and then do these manipulations after the thread is done. Your advise please.
|
|
|
|
|
Hello, the codegurus around the world.;)
I have the same experience about UpdateData (FALSE).
Even though I didn't do this, try to use SendMessage (or PostMessage)
to update Button stuffs by the user defined message.
I think that Timer is the good option.
BTW, why do you use UpdateData (FALSE)?
UpdateData(FALSE) updates the string by the memeber value in the class wizard
because you only use the control value in the class wizard.
Please, don't send me your email about your questions directly.
Have a nice day!
Sonork - 100.10571:vcdeveloper
-Masaaki Onishi-
|
|
|
|
|
et wrote:
2/ I tried UpdateData(FALSE) but it caused an Assertation Fail. Why?
Because MFC's design contains a map between HWNDs and CWnd objects. When you do any non-trivial operation on a window, MFC looks up the corresponding CWnd object in its map. However, each thread has its own map. Since the dialog was created by the main thread, the dialog is in the main thread's map. The worker thread can't find it in its map and asserts. (The previous calls work fine because it is safe to send messages between threads, which is what the calls boil down to.)
et wrote:
3/Maybe I should be using a timer in the Dialog to periodically check on the status of the worker thread
That's not the best way. Define a custom window message (WM_APP will do) and send that from the worker thread to the main thread right before the worker thread exits. Do your UI updating in response to that message.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hi All!
I made a dialog application. When I build it using the appWizard, I did not choose to have menu on the dialog. Now I need to have a menu, can I add it in?
Thanks in advance
Vu
vucsuf
|
|
|
|
|
Yes, just assign a menu to the dialog using the resource editor.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I am creating a 'server' that will talk TCP/IP to other devices. This server will need to be multithreaded. So questions. Does Winsock2 support threads? Some functions like WSAWaitForMultipleEvents and WSACreateEvent seems to 'be' threaded. Are there any examples of creating a socket server? Also interested in outright buying the sources for a professionaly built one.
Thanks
Ralph Krausse
|
|
|
|
|
|
Hello,
I am having difficulties dynamically creating a CScrollBar object in a CView derived class.
It seems to have a problem attaching to the window during the CScrollBar.Create() method.
The odd thing, all works fine in a dialog or CFormView class. I am quite stumped!
If anyone can shed some light on my problem, I would be very greatfull!
Thanks,
James
|
|
|
|
|
MSVC 6.0 SP4 Windows 98 second edition
On an application I am working on, the buttons on one property sheet dialog are disappearing intermittantly.
Cancel, Apply and OK are like disappearing, for no apparent reason. If you click the spot where they
would be, the BN_CLICKED message does infact work, and IDOK/IDCANCEL are sent, also
DoDataExchange works too.
WTHeck,
Asher
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
chk whether the buttons r set to OWNER DRAW or chk for other properties.
Ganesh Ramaswamy
|
|
|
|
|
Well,
the buttons are:
OK,APPLY and CANCEL...default properties.
ahoodin;)
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
then i am sorry. i dont have VC++ compiler now to test. it will take a week for me to get. so all the best and i am sorry
Ganesh Ramaswamy
|
|
|
|
|
No need to apologize,
you didnt do a thing wrong.
ahoodin
thxe09!
Real generosity towards the future lies in giving all to the present.
-- Albert Camus
|
|
|
|
|
Sounds like a resource leak or something weird happening with your Windows 98. Does this happen immediately? Have you tested with Windows NT/2000?
Regards,
Alvaro
|
|
|
|
|
Well,
The application hasn't been tested on a Windows 2000/NT platform... Primarily because the drivers have all been written in vxd format for the hardware. I did however fire it up in Windows 2000 for a kick after you sent the note. The MFC portions of the application appear to work. The application needs an additional redraw occasionally.
The Application skips through all hardware intializations as expected.
The buttons that were problematic dissappeared on the 98 box over a period of a few weeks of constant running.
BTSOOM,
ahoodin
He that breaks a thing to find out what it is has left the path of wisdom.
-- Gandalf, The Lord of the Rings
|
|
|
|
|
In the application I am working on, I am having an interesting problem.
When I enter the dialog, the first radio button in the tab order is
automatically checked. One of the screens has 3 radio buttons, and only 3. They are not grouped, nor do they have the tab order hint set. The dialog is a popup style modeless dialog.
BOOL man2::OnInitDialog()
{ CDialog::OnInitDialog();
CRect r2; //the button is not set!!!
main_dlg->GetDlgItem(IDC_GENERAL)->GetWindowRect(&r2);// get size IDC_GENERAL
// Set prog window right on top of IDC_GENERAL area of screen, and show it
SetParent( main_dlg->GetDlgItem(IDC_GENERAL)); // IDC_GENERAL set 2 parent window
//the button is set, for some unknow reason the first push button in the
// tab order has been activated!!!
SetWindowPos( &main_dlg->wndTop,0,0,r2.Width(), r2.Height(), SWP_SHOWWINDOW);
return TRUE; // return TRUE unless you set the focus to a control
}
This does not cause any problems if the first tab order item is a static
text box rather then a control. Currently I fix this problem in this way, however
I am looking for answers on this one. I am not happy with this Hack. I don't think
the answer is as easy as tab order or group setting. It is not the default behavior of the
radiobutton.
ahoodin
Whenever you have truth it must be given with Love, or the Message and the Messenger will be rejected.
-- Mahatma Ghandi
|
|
|
|
|
I want to make a internet connection checker app that disconnect the connection if it has past i.e 1 hour. My problem is: How to disconnect?
I know how to use the RasHangUp(..) but how can I disconnect when I don't have connected using RasDial(..)?
HELP!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I don't know about RAS. However when using a modem dialup to the internet. I usually use TAPI with the lineDrop method to drop a call. Of course you need to have opened the device through TAPI first.
Michael
|
|
|
|
|
I'm working on a DLL that initially did not have MFC support, and it also uses the WINAPI ENTRYPOINT construct for allowing access to it's functionality.
I changed the project settings to support MFC, and I know how to add a dialog box, but it doesn't come up like a normal app does. Instead, it saves it in a (resource?) "script". Further, ClassWizard is not available, even after the dialog resource is created in the project.
Can I just cut and paste MFC dialog box code into the class I create?
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I suggest you do it the other way around: create a fresh MFC DLL and then transfer all the old stuff to it. I've done this recently with a DLL of mine and had no problems at all.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Instead, it saves it in a (resource?) "script".
Click Project->Add to project->Files, and select the .RC file. That'll make the ResourceView tab appear.
--Mike--
http://home.inreach.com/mdunn/
Help! Help! I'm being repressed!!
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I did that and then the dialog wouldn't come up at all.
I ended up just doing what the first guy suggested, and it worked fine.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
This sounds simple: I just want to add a help button on a dialog's title bar.
Using the resource editor, I added the Context Help extended style.
The help button "Question Mark" shows up on dialog's title bar but nothing
happens when I click on it.
If I don't add minimize and maximize button to the title bar, the help button
works fine.
I am using VC++ 6.0 on win 2000.
Any help/suggestion will be appreciated.
Where there is a WISH, there is a WILL.
|
|
|
|