|
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
|
|
|
|
|
|
plz tel me code in vc++ (MFC) which is connected to mysql
plzzzzzzz.
Please mail me
|
|
|
|
|
Which part of this problem are you having trouble with? If you are needing a parameterized query, see here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
i dont use ODBC for connection i use mysql quires such as follows to connect
f ((myDB = mysql_init((MYSQL*) 0)) &&
mysql_real_connect( myDB, "localhost", "root", NULL, NULL, 3306, NULL, CLIENT_MULTI_STATEMENTS ) )
/*MYSQL *mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
const char *passwd, const char *db, unsigned int port, const char *unix_socket,
igned long client_flag) */
/*mysql_real_connect( myDB, "sanjeeva",
"root", NULL, NULL, MYSQL_PORT, NULL, CLIENT_MULTI_STATEMENTS ) )*/
{
if ( mysql_select_db( myDB,"gourav") < 0 )
{
MessageBox("Can't select the database !\nTry later.");
goto exit_here;
}
}
else
{
MessageBox("Can't connect !\nPlease try later.") ;
goto exit_here;
}
and now plz send me code to login
Please mail me
|
|
|
|
|
Hello,
I have a application UI developed using MFC, however the contents of the controls i.e. strings that needs to be displyed on the various controls(static texts, buttons, lilst boxes etc.) on the dialog boxes are determined at run time. So I need a Intelligent control resizing and positioning utility so that asthetics of the dialog box is maintained when one or the other control is stretched from its statically designed area.
This utility is also required for other purpose : I wish to internationalize my application and I do not want to maintain seperate resource DLL for each language supported by my application.
Any pointers or clues in this direction will be helpfull.
Thanks
Suyash
|
|
|
|
|
|
Hi Sarath,
Thanks, its of great help, in particular http://www.codeproject.com/useritems/SizingDialog.asp,
Though it doesn't solve my problem completely, i can re-use it.
However I still feel there should be some utility developed particularly for my problem, as its very generic requirement for multilingual application if we do not wish to maintain seperate resource dlls.
Anyways, Thanks much.
Regards
Suyash
|
|
|
|
|
Hi
I have one opensource of vc++. While executing this code it is giving the following errors.
1)error C2433: 'HWND' : 'inline' not permitted on data declarations
2)error C2143: syntax error : missing ';' before '{'
3)error C2447: '{' : missing function header (old-style formal list?)
4)error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
5)error C2086: 'int CALLBACK' : redefinition
If any one got these errors and knew the solution please let me know.
Thank You
angle
ThankU
angel
|
|
|
|
|
Can you provide more details of the code or code snap ?
How can we guess where the errors occures and why?
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
|
Can you be more specific its a little.
whitesky
|
|
|
|
|
I want to know how to find the HDD Serial Number from using C++ or C or any assembly code.
Thanks,
Anwar.
|
|
|
|