|
From studying various piecs of code and books, I inferred the following is the very basic code needed for a thread. Will it create and run a thread? If so, will ScheduleThreadProc continue to iterate without any form of coded loop? Thanks.
void CSchedule::startLoop()
{
AfxBeginThread(ScheduleThreadProc, this);
}
UINT ScheduleThreadProc( LPVOID pParam )
{
****my code here***
return 0;
}
|
|
|
|
|
Hello,
Oliver123 wrote: Will it create and run a thread?
Yes.
Oliver123 wrote: If so, will ScheduleThreadProc continue to iterate without any form of coded loop
No, the thread function is just like any function. It runs from begining to end. After it returns, the thread terminates. To keep the thread running, your ****my code here*** should define a loop.
Best,
Jun
|
|
|
|
|
There are two types of Threads:
1) User Interface Threads:
User-interface threads are commonly used to handle user input and respond to events and messages generated by the user.
For creating a user-interface thread derive a class from CWinThread.Then use RuntimeClass in the AfxBeginThread().
2) Worker Threads:
Worker threads are commonly used to complete tasks, such as recalculation, that do not require user input.
Creating a worker thread is a relatively simple task. Only two steps are required to get your thread running: implementing the controlling function and starting the thread.
This is what you are doing here. Creating a worker thread
Oliver123 wrote: Will it create and run a thread
Yes this will Create a thread and the control is transferred to ThreadProc.
Avoid using Terminate Thread etc when you do want to exit from a thread. Always return from the thread function.
Oliver123 wrote: without any form of coded loop
You need to have a loop in the thread function.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
And see here[^] maybe it is some helpful to you
|
|
|
|
|
Thanks. I put a for()loop with a sleep() and beep in the thread, and it beeps ten times just like it should.
|
|
|
|
|
Sorry for the stupid question, but i can't remember how and everything i tried didn't worked.
I tried: != "" , != "\0" , != String::Empty , and a lot more that didn't worked at all.
by the way i'm using visual studio 2003.
|
|
|
|
|
If I remmeber, the return value of SendMessage() is the number of characters copied to the string. Also before getting the text, you are supposed to set the first character in the buffer to the size of the buffer, so comparing to NULL is not going to work, you should check if it changed at all.
|
|
|
|
|
I'm not sure i'm following you, but you made me think to compare the length of the string to not 0 and it's working perfectly.
BTW to be sure we were talking of the same thing an editbox is a field you enter text in it and you access the text with ControlName->Text.
|
|
|
|
|
You MFCer's!! In plain win 32 we send a message to the edit box EM_GETLINE, but before sending that we must allocate a char* and set the first char to the size of the memory we just allocated. ie:
char tmp[128];
tmp[0] = '128';
int len = SendMessage(hEdit,EM_GETLINE,0,(long)tmp);
if (len == 0)
|
|
|
|
|
Ahhhh. That makes more sense.
|
|
|
|
|
What's wrong with sending the edit control a WM_GETTEXTLENGTH message?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello everyone!
Here, I have this statement:
#pragma once<br />
<br />
#include "Includes.h"<br />
<br />
class Game<br />
{<br />
Player mainPlayer;
<br />
VehicleType AllVehicles[1];
It generates these errors:
1>[dir]\Game.h(10) : error C2146: syntax error : missing ';' before identifier 'mainPlayer'<br />
<br />
1>[dir]\Game.h(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int<br />
<br />
1>[dir]\Game.h(10) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Why would it be? I'm pretty sure it's just some bad syntax I didn't see, that's why I included the surrounding lines... Any ideas? Thanks!
PS: Here's the declaration of Player :
#pragma once<br />
<br />
#include "Includes.h"<br />
<br />
class Player<br />
{<br />
int color;<br />
<br />
public:<br />
Player();<br />
<br />
SDL_Surface *surf;<br />
<br />
int x, y;<br />
<br />
bool Load(int color);<br />
<br />
bool SwapColors(SDL_Surface *surf, int color);<br />
};<br />
Windows Calculator told me I will die at 28.
|
|
|
|
|
#include "Player.h"
led mike
|
|
|
|
|
I think you are getting errors because you did not #include "Player.h" in Game.h . As you are creating an object of Player , therefore, the compiler should know what Player is.
Alternatively, you could try this syntax: (not always guaranteed to work)
class Player;
at the top of Game.h and #include "player.h" in Game.cpp .
this is this.
|
|
|
|
|
|
How about:
#pragma once<br />
<br />
#include "Player.h"<br />
<br />
class Game<br />
{<br />
...
Because includes.h is already included in Player.h . It should work.
this is this.
|
|
|
|
|
I am adding a single property page class to a property sheet a variable number of times in a modal dialog. Ideally I would like to adjust the tab caption from within the property page in response to a user adjustment to a caption edit field. Barring that, I would at least like to uniquely set the caption for each tab in OnInitDialog() or OnShowWindow() or from the property sheet on dialog startup. Calls to SetWindowText() seem to be happily ignored by the property page in those locations. Anybody have any experience/luck with this sort of thing?
Thanks in advance,
Scott
-- modified at 17:21 Monday 28th August, 2006
-- modified at 17:22 Monday 28th August, 2006
Scott P. Chapman
Voss Scientific Inc.
scottc@vosssci.com
|
|
|
|
|
Scott P. Chapman wrote: Anybody have any experience/luck with this sort of thing?
Use CTabCtrl::SetItem() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi!
Could anyone help me change the font of a button's caption/text in MFC?
The button is created with the modal frame style. The problem is that when I try to modify the caption's font, the application crashes.
The code which creates the button is:
m_wndButton.CreateEx(
WS_EX_DLGMODALFRAME,
_T( "Button" ),
_T( "Test button" ),
WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON,
CRect( 100, 100, 190, 140 ),
&m_wndView,
1,
NULL );
m_wndButton is the CButton object I'm trying to modify.
Can anybody give me a hint?
Thanks in advance!
|
|
|
|
|
Do you really need to create the button dynamically?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The application I am developing is Single Document (SDI). I do not have a dialog which can be modified at design time. The only dialog of this kind is the AboutBox. The button which I am trying to modify is contained on the main frame. It's on the child view exactly. I have no other choice (in my opinion), than to dynamically create the button.
|
|
|
|
|
m_wndButton.SetFont( &m_buttonFont);
where m_buttonFont is a CFont object declared in the View object and intialized to whatever font you desire or whatever.
led mike
|
|
|
|
|
Thanks a lot!!!
It finally works! The only thing that was wrong was the declaration of the CFont object: instead of declaring it in the CMainFrame class, it was declared in the same method the button was created in.
|
|
|
|
|
|
can we change the initial size of the onscreen keyboard???and also hilight the button we pressed???how about if i wan to create a button when pressed it automatically do this operation which is CTRL+ALT+DELETE...which we would wan to do it so that the task manager appear...how about creating shortcut key to application like Microsoft word and notepad...is it possible ?pls reply or help me cause i am doing a project on it...In need of help...!thx ....
|
|
|
|