|
Do it like this:
In header:
private:
BOOL m_bWorking;
public:
void DoScan();
static DWORD __stdcall ThreadScanner(LPVOID lpVoid);
-----
In OnInitDialog()...
m_bWorking = FALSE;
-----
In OnStartScan()...
DWORD id;
CreateThread(NULL,0,ThreadScanner,this,0,&id);
CButton* pButton = (CButton*)GetDlgItem(IDC_BTN_EXIT);//IDC_BTN_EXIT is the id for your Exit Button.
pButton->SetWindowText("Stop Scan");
m_bWorking = TRUE;
-----
DWORD __stdcall CScanDlg::ThreadScanner(LPVOID lpVoid)//where CScanDlg is you dialog class.
{
CScanDlg* pParent = (CScanDlg*)lpVoid;
pParent->DoScan();
return 0;
}
-----
In OnScan()...
while (m_bWorking)
{
Do the scanning here...
}
-----
in OnExit()...
if (m_bWorking == FALSE)
CDialog::OnCancel();
else
{
m_bWorking = FALSE;
CButton* pButton = (CButton*)GetDlgItem(IDC_BTN_EXIT);
pButton->SetWindowText("Exit");
}
Any problems understanding the code?
Please say if it does not work.
Happy Coding.
this is this.
|
|
|
|
|
khan++ wrote:
CreateThread(NULL,0,ThreadScanner,this,0,&id);
Since this is an MFC application, AfxBeginThread() must be used.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello,
I am writing an application in which user can type sentences.I need to change colors some keywords in that sentence into blue. How can i accomplish this task in VC++.
Thanks in advance ,
John.
|
|
|
|
|
You don't give us a lot of useful informations ! What kind of application are you doing ? Console, Win32 ? With or without MFC ? And where is this text written ? In a control or what ?
|
|
|
|
|
Thanks for the fastest reply.
I am developing a SDI application using MFC and the text will be written in the SDI's views . I am currently not using any kind of special controls.
Once again,Thanks.
John.
|
|
|
|
|
emmatty wrote:
I am developing a SDI application using MFC and the text will be written in the SDI's views
Easiest way to Get above would be use CRichEditView instead of CView!.
And Cedric -I am back in race
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Is CDC::SetTextColor of any help ?
|
|
|
|
|
Long time no see Bro
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Yep . You were in hollidays ?
|
|
|
|
|
cedric moonen wrote:
You were in hollidays ?
Yeap, celebrating holiday in hospital since last thursday due to intestine infection . Now All ok!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Ouch.... Not so funny holidays
|
|
|
|
|
Hi
Please i want some information related to OpenGL and win32 Dialog
Actually i want to show open Gl window in the right corner of my dialog.
i want to create so that animation remains runninig in its own openGL window and i can give other controls on the left side
If anybody knows please help me.
Give me some link of tutorial or some link of sample code or if you have any such application you can send me or if you have any idea please let me know
i Will be very thankful to you;
Always be Happy When things done
|
|
|
|
|
Does any article here[^] help ?
|
|
|
|
|
There are a two main steps involved in this:
(1) You derive a CWnd class and overwrite its OnPaint(..) function to draw a GL window. You'll also need to setup pixel format, create a context using wglCreateContext(..). All this fairly generic and there are several examples on the net that combine MFC and GL. You must create this window using CWnd::Create(...) function in the CDlg::OnCreate().
(2) Now, the trick is that you position this window on the dialog where you want to draw. In order to do this you must call the OnSize(..) function of the dialog and then do MoveWindow on the derived CWnd class. In order to correct positioning for the top left corner, you can place a static resource on the dialog roughly where you wish to draw, and then use GetWindowRect(..) to find the coordinates. Bottom right coordinates are easy to find if you know the width and height of the window. Perhaps you can use the OnSize() params.
This is pretty much it. Please let me know if you face any problem.
Swati
|
|
|
|
|
I need to create a macro like TRACE to handle variable arguments but i can't seem to find it in vs folders. Any ideas?
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
IIRC TRACE simply expands to AfxTrace in Debug builds using MFC. AfxTrace is a function which takes a variable number of parameters.
Visual C++ does not support vararg macros, which are a new feature in C99 but not yet in the C++ standard.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
this is basically what TRACE does:
void MyTrace(const char* fmt, ...)
{
char buffer[1024];
va_list argptr;
va_start(argptr, fmt);
_vsnprintf(buffer, 1024, fmt, argptr);
va_end(argptr);
OutputDebugString(buffer);
}
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
However, if you were to write your own, I would break the resultant string up into lengths of text no longer than 256 bytes.
Some debuggers interpeting the results from OutputDebugString used to have trouble with strings over 256 bytes in length.
If you split it up into lengths of about 70, it would be easier to read in the output window too!
|
|
|
|
|
So how is the TRACE marco being defined?
#define TRACE ???
<font=arial>Weiye Chen
Life is hard, yet we are made of flesh...
|
|
|
|
|
|
Well, i would like to have a button in my programm, that will open my default mail client programm (Outlook 6, Outlook 2003 or smth. else) and make a message to be send with attachement. So... I tried the way with shellExecute, but i don't know is it possible to insert a file as attachement to the message or not... If it's available - i would appreciate your help...
Thank you very much...
|
|
|
|
|
Hi,
The MFC Document/View Architecture has this facility.
For simple program with sending mail from File menu u can follow this method:
1 . Add a menu item with ID: ID_FILE_SEND_MAIL
2 . Add these to Application document’s message maps:
ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail)
ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL,OnUpdateFileSendMail)
Compile and Build.
Up On testing the default mail clients will be opened, u can even add an atachement to it.
Regards
jsk
|
|
|
|
|
See here.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hello All,
I am working on screen saver, which need to display an Image in different ways i.e. coming from bottom/top , fading in or fading out or more. I would love to make these by my own, But i have no time left to do so and deadline is approaching , So i am going after any ready made solution offcourse with Source Code!.
Please somebody point me in right direction to accomplish above task! thanks
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|