|
What type of project are you using ? SDI or MDI ? If it's SDI, I think you have to create it on the view, and not on the mainframe.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
its an SDI application....
the code i've used is
CLed m_led; ///declared in mainframe.h
m_led.Create(...);// in the OnCretae of mainframe.cpp
here CLed is a class derived from CStatic which gives some special features to a static control...
|
|
|
|
|
Did you read and tried the solution that people gave you ? I'm almost sure that Viorel got the point. Did you tried it ?
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hey All,
I am using the common open and close dialog boxes used in windows, i.e. OPENFILENAME, GETFILENAME. I can get them to open in the desired directory and have created a filter to display my applications propriatary file type. My problem is that I need to create a filter to display only certian files of that file type.
Example: I have 5 files using .txt
Using my current filter all files of type .txt will be displayed
bob.txt
foo.txt
bob_again.txt
bar.txt
bob_yet_again.txt
I want to be able to display only files that have bob in the title
bob.txt
bob_again.txt
bob_yet_again.txt
I cannot find any information on if this is even possible.
Does anyone know if this is possible?
If so how is it accomplished?
Thanks for your time
Nitefall------------Lost in the land of Win32
|
|
|
|
|
Nitefall2060 wrote: I want to be able to display only files that have bob in the title
Have you tried:
ofn.lpstrFilter = _T("Bob files (Bob*.*)\0Bob*.*\0");
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
We appear to think alike becasue it was the very first thing that I tried.
Unfortunatly this causes everyfile in the entire directory to be displayed,
it no longer even limits the file to the .txt files.
I know you can delimit a string in borne shell or perl the way I want but I have never tired it in windows.
|
|
|
|
|
I tried this and it worked fine:
void main( void )
{
OPENFILENAME ofn = {0};
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = _T("Bob files (Bob*.*)\0Bob*.*\0");
GetOpenFileName(&ofn);
} What else do you have?
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
After messing with this a bit I also got it to work. Thanks alot.
I am now having issues with a variation of this, I am trying to get the name my save and load dialog boxes display, to be dynamic based on the file the user is currently working on.
My application creates several files based on the original file.
For Example: if a user names the original file bob my application will create a bob_section1.txt and a bob_section2.txt.
The purpose of this filter is to only display the files that were created durring a single run of my application.
bob.txt
bob_section1.txt
bob_section2.txt
I can get the filter to work if I statically put in ofn.lpstrFilter = "Bob files (Bob*.*)\0Bob*.txt\0"; Or using a character array called Filtername[256] and building the same filter.
Filtername[256] = "Bob files (Bob*.*)\0Bob*.txt\0";
ofn.lpstrFilter = Filtername;
What I am trying to acomplish is the following
Filtername[256] = "Section files (.txt)\0Filename*.txt\0";
Where Filename is the name of the current file. This way it will display the created file and all of the secondary files created from it.
I have tried
strcpy(Filtername, "Section files (.txt)");
strcat(Filtername, "\0");
strcat(Filtername, Filename);
strcat(Filtername, "*.txt\0\0");
This however fails miserably and I get either No files to display or every file in the entire directory. I am pretty sure it is an issue with the null charcters not getting put into the character array correctly but I am not sure what exactly is going wrong.
Any Ideas.........
Nitefall
|
|
|
|
|
Nitefall2060 wrote: This however fails miserably...
Because of the embedded \0 character(s).
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Because of the embedded \0 character(s).
Drat, I thought as much... Is there anytype of work around for this or is my dream of dynamic naming dead.
|
|
|
|
|
You could use memcpy() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for all your help I got it working now.
The final version came out looking like this
// Creates appropriate filer without loosing the embeded NULL characters
strcpy(Filefilter, "Scenario Files (*.txt)\0");
strcat(Name,"*.txt\0\0");
strcpy(&Filefilter[23], Name);
ofn.lpstrFilter = Filefilter;
Again thanks for all of your advice David
Nitefall2060
|
|
|
|
|
strcpy() and strcat() won't work with embedded \0 characters. You'll either need to use memcpy() or plug the \0 characters in manually.
Another option would be:
char szFileFilter[256];
sprintf(szFileFilter, "%s%c%s%c", "Scenario Files (*.txt)", '\0', "*.txt", '\0');
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If I put an activeX control on a CDialog in an MFC dll, the dilaog doesn't come up. WHy is this? Can I get around it somehow?
thanks,
sb
|
|
|
|
|
Make sure that AfxEnableControlContainer() is called at the begining of your InitInstance function (sorry, for dll I can't remember if the function is the same name).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
how we can set the co-ordinates for popup dialog box in runtime.
sree
|
|
|
|
|
|
SetWindowPos()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
My app has a processing thread, when the thread end it sends (Postmessage) an WM_USER to the main frame (using a pointer that is initialized into CDocument, before that the thread starts, using AfxGetMainWnd).
Then that message is used to know that the process is end.
It works perfecly ,.... but I have notice that if the user, during the processing, opens (and explore) the program menu the user message will not reach the main frame, and I can't know that the thread is end!
Does somebody know what is the reason of this?
Thanks.
Cheers,
Russell
|
|
|
|
|
I think the WM_USER message sent by your thread can interfere with another messages used by Windows. There are many reserved messages defined as WM_USER + num in Windows header files. So it is possible that your message is interpreted in an unexpected way.
In order to avoid collisions, you can use "registered messages" instead, defined with RegisterWindowMessage function. The corresponding handler can be defined using ON_REGISTERED_MESSAGE macro.
Or you can post the WM_COMMAND message with a unique command ID which is not used by any menu item.
Alternatively, you can found another ways for detecting thread completion. For instance, in your main application you can use something like this: WaitForSingleObject(*myThread, INFINITE) , where myThread is a pointer to CWinThread object, returned by AfxBeginThread .
|
|
|
|
|
Thanks :-Dfor your resp.
the message collision could be athe problem.
I'm also thinking that some function used to draw the menu can get my message and it doesn't like it and so delete the message.
Do you know if the "registered messages" can solve this problem too? (I haven't used they before)
And, finally, WaitForSingleObject looks like a function that will lock the application in a loop waiting that the thread ends, Am I right?
Thanks
Cheers,
Russell
|
|
|
|
|
The RegisterWindowMessage function defines a new window message that is guaranteed to be unique throughout the system [MSDN]. Therefore no collision will occur.
The usage of RegisterWindowMessage in context of MFC is simple. In your frame class (*.h file), define a handler like this:
afx_msg LRESULT OnMyMessage( WPARAM, LPARAM);
Then in *.cpp file declare a static variable:
static const UINT myMessageID =
::RegisterWindowMessage( "put here a long string");
And then in BEGIN_MESSAGE_MAP area add:
ON_REGISTERED_MESSAGE(myMessageID, OnMyMessage)
* * *
The WaitForSingleObject can be used in non-blocking form:
if(WaitForSingleObject(*myThread, 0) == WAIT_OBJECT_0)
{
}
else
{
}
You can specify a non-zero timeout interval in WaitForSingleObject .
Hope your problem does not have other subtle reasons.
|
|
|
|
|
Viorel. wrote: Hope your problem does not have other subtle reasons
Me too!!
Thanks
Cheers,
Russell
|
|
|
|
|
i want to login in mfc and it cofirm username and password from mysql table
hi plz plz its urgent
tel me code ::::::::::::::::
plz tel me code for my problem which is as::::
my problem is related to login
i make a dialog box in mfc(vc++) which contain two edit boxes one for username and one for password
and it contain a ok button
to which when we click it give the second dialog box if username and password r right else not
but as username and password r stored in mysql table so it check in mysql table and then match wheather they r correct or not
note::: if possible then plz mysql table can store no of usename and passwords
if two username and password r stored in table and when i enter one username and password then it check that one and open one dialog box
and if i enter other username and password then it open another dialog box
Please mail me
-- modified at 8:31 Friday 9th June, 2006
|
|
|
|
|