|
How can I show a modeless dialog in a separate thread ?
Ex: I wrote a app as dialog, let's call it CMyProgDlg
I have a button, whenever I press at that button, it calls a function( let's call it
static void Thread(LPVOID lParam)
This function shows a modeless dialog. This modeless dialog run in a thread. I tried AfxBeginThread(Thread, this) in CMyProgDlg, but it failed.
Anyway ?
Thanks
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
You don't really need to create a modeless dialog using a separate thread because the parent dialog or window is still accesible and can process messages.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
You've got it backwards. Assuming you really do need a thread -- have the modeless dialog create, control, and abide by the thread, instead of the other way around.
Regards, Larry Antram
Stardust Software
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
-- Albert Einstein
|
|
|
|
|
I'm trying to read the contents of a text file, then put it in an Edit control using SetDlgItemText(). I'm using CStdioFile::ReadString(CString), but that only reads the first string of the file. I'm kind of new to Win32 and MFC, so I'm not sure how to read the entire contents. Any help would be appreciated.
Thanks, Emearg.
|
|
|
|
|
Did you try calling ReadString until it returns NULL? It doesn't actually say to do this in the documentation, but it will probably work. Otherwise look at CFile.
Like it or not, I'm right.
|
|
|
|
|
Alright...
I declared a bool variable called 'done', and tried to use it in a loop like this:
while(!done)
{
if(File.ReadString(LogString) == FALSE)
done = true;
}
I did false because CStdioFile::ReadString returns BOOL types.
That should work, but it doesn't. When I click the button that calls the function that snippet is in it doesn't do anything. If I put just a simple call to the ReadSting() function then it reads the first string.. but that loops makes it read nothing... I dunno what's wrong. =/
thanks, emearg
|
|
|
|
|
Loop a call to ReadString. You'll get a NULL or a FALSE when EOF is reached depending on which over-ride of the function you are using.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Sweet, I added this:
if(File.Open(FileName, CFile::modeRead | CFile::typeText))
{
while(!done)
{
if(File.ReadString(LogInput) == FALSE)
done = true;
LogString += LogInput;
LogString += _T("\r\n");
}
}
And that did it. It looks exactly like the text file, thanks everyone that helped
|
|
|
|
|
We as programmer often need collecting many information from the web. iBee is such a good tool let programmer save exact content from the web, yes, you needn't save anything you dislike such as Ads Picture, Frames. just select the content you want and drop it, you will get what you want. What's more, you can edit the content in Internet Explorer! and then build all articles into a eBook in CHM Format.
iBee is especially optimized for codeproject users, iBee will download all zip or exe files.
you can find this cool tool at www.justdosoft.com. if you give me some advices, I will give you a copy of iBee free, thank you.
Screen Shot
|
|
|
|
|
Hi I have used this code for a UI in a dll.
<br />
<br />
CNewApp * thread = (CNewApp *) AfxBeginThread(RUNTIME_CLASS(CNewApp),THREAD_PRIORITY_NORMAL,0, CREATE_SUSPENDED);<br />
<br />
I get the following compile error
error: C2039: 'classCNewApp' : is not a member of 'CNewApp'
Note the no space in the error
Why Why Why??
CNewApp is of type CWinApp with is of type CWinThread
---
|
|
|
|
|
Does you CNewApp class contain a DECLARE_CLASS statement?
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
THis is how I declared my class
<br />
class AFX_EXT_CLASS CNewApp : public CWinApp<br />
{<br />
DECLARE_DYNCREATE(CNewApp )<br />
CNewApp ();<br />
virtual BOOL InitInstance();<br />
};<br />
<br />
IMPLEMENT_DYNCREATE(CDialogThread, CWinApp)<br />
BOOL CNewApp ::InitInstance() <br />
{ <br />
...<br />
}<br />
|
|
|
|
|
Why are you trying to create a CWinApp object? You ought to be using a direct derivation of CWinThread.
Signature space for rent. Apply Within.
|
|
|
|
|
ok... I've had problems with unhandled exception error before... but right when i fixed it, i kind of forgot what i did to fix it... this is my code... "im posting it all.. except my header file, just to make sure you know what im doing."
#include <iostream>
#include "Class.h"//included header "Class.h"
using namespace std;
Name person; //class def person
int NN = 1;//incriment
char Names[21]; //total amount of names
char SName[100];
//SetName function.
bool Name::SetName(char* NName)
{
if(!NName)
{
return false;
}
int NLen = (strlen(NName) + 1);
char *NewName = new char[NLen];
if(!NewName)
{
return false;
}
strcpy(NewName, NName);
delete[] M_Name;
M_Name = NewName;
Names[NN] = *M_Name;//I think it has somthing to do with this
NN++;
return true;
}
const char* Name::GetName()
{
return M_Name;
}
//main
int main()
{
for(;;)//main loop
{
gets(SName);
person.SetName(SName);
cout << person.GetName() << endl << endl; //print name that you just typed.
for(int inc;inc < NN;inc++) //print all names.
{
cout << Names[inc] << endl; //error unhandled exception.
}//end of print all names, loop.
inc = 1;
}//end main loop.
return 0;
}
//end main
//constructor & deconstructor
//*******************
Name::Name()
{
M_Name = NULL;
}
Name::~Name()
{
delete[] M_Name;
}
The error accured when i tried to set Names[NN] = *M_Name; the error feels like its at the tip of my tongue, yet i cant think of it.
Thanks all for the help!
~SilverShalkin
ps... how do you show a screen shot of your code? or post your code on CP with its background different... "is ther a place on the forum that shows how?"
Thanks!
|
|
|
|
|
for(int inc;inc < NN;inc++)
must initialize inc = 0;
soptest
|
|
|
|
|
I didn't even look through the code, but that is truly awesome.
SilverShakin - step into the debugger sometime to see what amazingly huge negative numbers an unassigned int gets as a default value. One thing I like about C# - it sets sensible default values for variables.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
M_Name is probably NULL and you're trying to deference it.
You can make your code look different by wrapping it in a <pre> tag, but of course then you need to type & lt and & gt ( without the space ) to get your < > characters.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
int the for loop
the
for(int inc;
the int initializes, or defines inc as an intiger... therefore i do not need to define it anywhere else... but ill look over it and see if i made a mistake...
Thanks all!
M_Name is = NULL,.... hmm im thinking... ill go and change some things... if i cant figuere it out, ill jump back on
Thanks again!
~SilverShalkin
|
|
|
|
|
The problem is exactly as has been stated - you define an integer, but do not give it a value. It's value will be in the order of -80,0000. You need to put int inc = 0, not just int inc.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
ok, ok... i thought you ment that i had to int inc... and i responded by that i have already... but i got the main point... i changed the for n loop to:
for(int inc = 0;inc < NN;inc++)
and it worked.. thanks! But i still have the problem with the unhandled... i didnt have time to change some things but, ill keep your responses in mind
thanks for the help all!
~SilverShalkin
|
|
|
|
|
Have you traced to see if your variable being referenced is NULL, or added a check to alert you to this case ? Checking if a variable is valid is always good - initialise all pointers to NULL, check if they are NULL before dereferencing or calling methods on them.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
please initialise the Loop Running variable mnc in to zero..
ie you must for(int mnc=0;mnc
|
|
|
|
|
i did set it = to zero,... for the most part, that fixed it
Thanks!
~SilverShalkin
ps... I'll work the debugger on the NULL pointers
Thanks!
|
|
|
|
|
I need to be able to create an image where I can specify a point (this one being the center) and a second point that is X° from the first point. I then need to be able to draw a straight line from point 1 to point 2. It would also be nice if I am able to label both points. The two points represent the direction or bearing from the first point (From) to the second point (To). This is for the web, so I thought that Office Web Components would be best. If it would be simpler to create something in C++ and then to just call a function to produce this image, I would be very appreciative if someone could point me in the right direction. I don't regularly do C++ development, but have played with it in the past.I will know the X° that the 2nd point is from the first. Does anyone have any ideas for this? Thanks in advance.
Nick Parker
|
|
|
|
|
Can anyone help me fix this. i am trying to sort the y's of my sprite from highest to lowest values and then print it out. this is what i have but my compiler wont compile it. can anyone kind enough to help me fix this to allow it work. anyways, thank you very very much. i really appreciate it.
#include <iostream>
using namespace std;
struct SPRITE
{
int x;
int y;
};
// Maximum number of sprites
const int N_SPRITES = 10;
// Array of sprites
SPRITE sprites[N_SPRITES];
bool Compare (const SPRITE &one, const SPRITE &two);
/* Pre: Enter a Sprite value for one and two
* Post: Compares all of both strings
*/
int main()
{
int value;
for (int i=0; i<n_sprites; i++)
="" {
="" cout="" <<="" "enter="" a="" value:="" ";
="" cin="">> value;
sprites[i].y = value;
}
int* begin = &sprites[0];
int* end = &sprites[9];
sort(begin, end, Compare);
for (i=0; i
|
|
|
|