|
|
Hi Developers,
I am using a MDI based application. I am trying to open a view and it's showing the background image on it. It's like overlaps it's own screen and background screen. I have not used any drawing function at all.
Can any one help me.
Thanks in Advance.
Amrit Agrawal
Software Developer, Mumbai
|
|
|
|
|
Amrit Agr wrote: it's showing the background image on it. It's like overlaps it's own screen and background screen.
I am having difficulty visualising exactly what you are seeing. Rather than 'it' can you explain which part of each window is showing what values. What do you see in the Main window, what do you see in the View, and where is the background from?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
i want to print two parameter from my struct but it doesnt print to me
GetWindowText(hwndEdit[0],arr.last,10);
GetWindowText(hwndEdit[1],arr.first,10);
MessageBox(hwnd,TEXT((LPCWSTR)arr.last(LPCWSTR)arr.first),TEXT("bla"),MB_OK);
how can i fix\what is the syntax ?
|
|
|
|
|
You can only pass a single string to the MessageBox() function. Use sprintf() or the appropriate variant to create a single character array containing your complete message.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
The problem is with your conversion..
Cheers
|
|
|
|
|
You need to concatenate the strings first before you call MessageBox .
As Richard said, you can use sprintf to do this.
If you have wide character strings, you must use the swprintf function instead.
You could also use the _stprintf (or _stprintf_s ) macro which would cater for both sprintf (sprintf_s ) or swprintf (swprintf_s ) depending on whether UNICODE is defined.
You can also use the _tcscat (or _tcscat_s ) macro to do this.
Other options are to use the CString += operator or the std::wstring += operator .
|
|
|
|
|
Hi all,
I have made a dialog based application, and in that application i have a tree as well as list control.
What i want is, when i click on a item in tree control my corresponding item in List control should get its font bold or should change its text colour.
I was trying to do it using customcontrol method but its not working.
how can i do this???
|
|
|
|
|
VCProgrammer wrote: I was trying to do it using customcontrol method but its not working.
Since we cannot see your code it's impossible to suggest what you may be doing wrong. Try editing your question and adding the code (within <pre> tags) that you are having trouble with.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
I've created win32 API project for work with mysql. Each window form has *.cpp file. In window "main.cpp" I created connection to MySQL database via variable MYSQL * mysql5. Another window named "income" (income.cpp) must use variable "mysql5" to create a question.
How can I obtain the value "mysql5" in file income.cpp?
main.cpp:
#include "main.h"
mysql_real_connect(mysql5, HOST, USER, PASSWORD , DATABASE , PORT, UNIX, 0 );
main.h:
static MYSQL *mysql5;
income.cpp:
mysql_query( mysql5, "question" ); //now suddenly mysql5 is null
modified 13-Jan-12 17:24pm.
|
|
|
|
|
Global is probably not the best option in C++, but I'll answer your question nonetheless...
In main.h, where did you declare mysql5? Is it in the global namespace or is it in a class? If it's in the global namespace, you probably have to remove the static declaration since that'll limit the visibility of the variable.
Assuming it is in the global namespace, in income.cpp, did you remember to declare mysql5?
extern MYSQL *mysql5;
Lastly... in C++, it's probably a better idea to use a member variable and pass the parameter that way when the object is constructed or through a Set() method.
|
|
|
|
|
Thank you for the answear.
If I remove the static declaration I receive errors like this : error LNK2005: "struct st_mysql * mysql5" (?mysql5@@3PAUst_mysql@@A) already defined in main.obj.
Adding
extern MYSQL *mysql5; do nothing.
Here are details:
main.h:
#include "ClassLogin.h"
static MYSQL *mysql5;
static ClassLogin *login2;
DlgLogin.cpp - contains dialog procedure and #include "main.h"
case button_OK:
ClassLogin * login = new ClassLogin(...parameters...);
login2 = login;
ClassLogin.cpp:
#include "main.h"
#include "ClassLogin.h"
ClassLogin::ClassLogin();
ClassLogin::ClassLogin(...parameters...)
{ ... mysql_real_connect(Cmysql, host, user, password , database , port, unix, 0 );
mysql5 = Cmysql; }
destructor
Class ClassLogin
{
public:
ClassLogin();
ClassLogin(...parameters...);
MYSQL *Cmysql;
virtual ~ClassLogin();
};
income.cpp - contains dialog procedure and
#include "main.h"
#include "ClassLogin.h"
MYSQL * mysql2;
case button_OK:
mysql2 = login2->Cmysql;
mysql2 = mysql5;
But if I don't use login2->Cmysql or mysql2 = mysql5 the values are right (0x01df0a98) while debuging (F5)
What I have to do to obtain values from class ClassLogin in another cpp file?
Jan
|
|
|
|
|
You may:
in main.h remove the line
static MYSQL *mysql5;
in DlgLogin.cpp add the line
MYSQL * mysql5;
in income.cpp add the line
extern MYSQL * mysql5;
Now the variable in income.cpp is exactly the same of DlgLogin.cpp so no assignemnt is required.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you. This function.
|
|
|
|
|
Well, I had no doubt about...
You are welcome.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I have a two folded question
1) How to respond to
WSAETIMEDOUT in the OnConnect override for CASyncSocket
where nErrorcode = WSAETIMEOUT
2) My CASyncsocket class "Mysocket" is a member of CWinThread Class as I want to make where
the socket class lives the highest priority
if the answer to question 1 call CASyncsocket::connect again then how would I obtain
my CWinThread class which has my CAsynsocket class a member
for example
MyCAsynSocket* currentthread;
class MyCwinThread : public CWinthread
{
.
.
.
.
CAsynSocket MyCAsynSocket;
CString ipaddr;
UINT port;
}
currentthread = (MyAsynSocket*) = AFxGetthread(): //
currentthread->connect(currentthread>ipaddr,currentthread->port);
Thanks
|
|
|
|
|
Not sure what you are trying to explain or do here, but this line of code looks really incorrect.
currentthread = (MyAsynSocket*) = AFxGetthread():
Also in terms of trying to connect again, can you not wrap the connect call within some kind of loop operation?
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Dear Friends
I am loading a dll from another exe mfc application. for that i have exposed one api 'runAppli' in the dll as extern "C". Then I am loading the dll using LoadLibrary. By loading the dll itself the dll application is launched. I am surprised. I should call the api 'runAppli' and then the application should launch but its not happening. How come it is happening please give some suggestions.
[code]
// in the all
extern "C" BOOL __declspec(dllexport) runAppli(CString filename)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if(filename.IsEmpty())
return false;
view->ShowWindow(SW_SHOW);
view->loadProfile(filename);
view->domainSetUpForProfile();
view->drawLines();
view->drawArcs();
view->drawProfile();
return true;
}
//in the client exe application
void CClientRevolutionProjDlg::OnBnClickedButton1()
{
HINSTANCE hinstLib;
hinstLib = LoadLibrary(L"C:\\Users\\sujan.dasmahapatra\\Documents\\Projects\\Bhagavan_SurfaceRevolution\\RevolutionProj\\debug\\RevolutionProj.dll");
}
[\code]
By simply loading the dll the dll application is launching.. why ??? Thanks Sujan
|
|
|
|
|
it's impossible for us to say, without knowing what the DLL has in its DllMain (or CWinApp::InitInstance).
|
|
|
|
|
Hi,
The MFC DllMain function will automatically call InitInstance when your DLL is loaded and it also calls ExitInstance when the DLL is unloaded.
You might be able to get around this by providing your own DllMain function:
HOWTO: How to Provide Your Own DllMain in an MFC Regular DLL[^]
I don't really recommend providing your own Dllmain function... you could probably prevent the window creation by modifying your InitInstance and removing/moving the window/view initialization.
Best Wishes,
-David Delaune
|
|
|
|
|
Hello,
Ive been programing in MFC for a while.
And now i would like to learn MFC deeper and to understand better what is going on behind the scene.
What good books exist for learning MFC?
|
|
|
|
|
|
Hi,
I got a
WSAEWOULDBLOCK return code from the connect method would the proper
response be to retry the operation until I get a Zero return code
|
|
|
|
|
As MSDN suggests[^]:
If this indicates an error code of WSAEWOULDBLOCK, and your application is using the overridable callbacks, your application will receive an OnConnect message when the connect operation is complete
you shouldn't call again the Connect method because the connect operation is in progress after method returns. Viceversa, you should override the OnConnect method (see the example in its documentation[^]) to know when the connect operation is completed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|