|
|
Thanks
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
Hi,
There are many dialog boxes in my project. I want to know that which one is active at a certain time. For example;
CDlg1 * dlg1;
dlg1= new CDlg1;
dlg1->Create(IDD_DIALOG1,this);
CWnd * wnd;
wnd = (CDialog*)GetActiveWindow();
if(wnd == dlg1)
wnd->DestroyWindow();
I wrote this code to close the window. How can I know that which wnidow is active?
Thanks
|
|
|
|
|
You can use GetFocus() Or GetForeGroundWindow() functions.
Regards,
Sandip.
|
|
|
|
|
These are not working in my situations.I think the problem is not about GetActiveWindow(). The problem is that when I want to know if this window (active window) is the same window with the dialog box that I created before, it couldn't compare them. This part has problem I think;
if(dlg == wnd)
|
|
|
|
|
iayd wrote: CDlg1 * dlg1; // A global object for the dialog box.
dlg1= new CDlg1;
dlg1->Create(IDD_DIALOG1,this);
Since you're creating your child dialogs by passing your main dialog as parent, call GetTopWindow() by passing parent window handle . It will give you the top most window of your application.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks. That solved the problem.
|
|
|
|
|
iayd wrote: if(wnd == dlg1)
Use window handles instead of MFC objects to compare. Since MFC window objects are just wrappers around window handles.
if( wnd.GetSafeHwnd() == dlg1.GetSafeHwnd() )
;;//...
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I am using Standard SDK 500 and EVC++ to develop my UI application.
I have added an edit box to input barcode in my main dialog window.
I want to show soft input panel on my dialog when my cursor hovers over the edit box
to input barcode .
How do I do that?
Ema
|
|
|
|
|
I have a class as...
class Log
{public:
Log(string);
void InitializeLog(string);
...
class Initialize
{ public:
Initialize(string);
void ReadPropfile(string);
....
};
};<pre>
next I am doin this...
<pre>void Log::InitializeLog(string p_path_name)
{
Initialize obj(p_path_name);
obj.ReadPropfile(p_path_name);
}
void Log::Initialize::ReadPropfile(string log_path)
{....}
From the main I call...
Log obj(path);
obj.InitializeLog(path);
...
When I compile I get the following error. How do I get rid of this
test_utility.obj :error LNK2001: unresolved external symbol "public: __thiscall Log::Log(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >)" (??0Log@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@
@std@@@Z)
properties.obj : error LNK2001: unresolved external symbol "public: __thiscall Log::Initialize::Initialize(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >)" (??0Initialize@Log@@QAE@V?$basic_string@DU?$char_tra
its@D@std@@V?$allocator@D@2@@std@@@Z)
THANKS
|
|
|
|
|
pl_kode wrote: class Log
{public:
Log(string);
forget to implement constructor for Log? Log::Log(string) ?
pl_kode wrote: class Initialize
{ public:
Initialize(string);
And Initialize::Initialize(string) too?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi,
how can I get data from edit control in a integer?
|
|
|
|
|
You can use GetDlgItemInt(IDC_EDIT1) function.
Regards,
Sandip.
|
|
|
|
|
Actually this is double value
|
|
|
|
|
What does that mean?
|
|
|
|
|
Then as toxcct said
You take entire string using GetDlgItemText()
and use atof(),... functions depending on your value type whatever you wanna use.
or
Using Class wizard add the data member variable for that control with appropriate data type.
and call UpdateData().
Regards,
Sandip.
|
|
|
|
|
Use atof() for converting string to double.
CString csValue;
GetDlgItem(IDC_EDIT1)->GetWindowText( csValue );
double dValue = atof( csValue );
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Jijo raj wrote: CString csValue;GetDlgItem(IDC_EDIT1)->GetWindowText( csValue );double dValue = atof( csValue );
The above code gives me error :
error C2440: 'type cast' : cannot convert from 'class CString' to 'char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
in eVc++4.
How do I solve this error.
Thanks
Terry
|
|
|
|
|
Try this.
double dValue = atof((LPCTSTR)csValue );
The previous code snippet compiles perfectly in Visual Studio 6.0. Might be you got the error because of eVc++4.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Jijo raj wrote: double dValue = atof((LPCTSTR)csValue );
Redundant cast.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
On trying you code you provided, I get :
Jijo raj wrote: double dValue = atof((LPCTSTR)csValue );
: error C2664: 'atoi' : cannot convert parameter 1 from 'const unsigned short *' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
I am working with eVC++4 on WinCE MFC application. Hope to find some alternative to the problem.
Thanks
Terry
|
|
|
|
|
Jijo, got it working as :
<pre>
CString csValue;
GetDlgItem(IDC_OpNo_EDIT)->GetWindowText( csValue );
int no = atoi((char*)(LPCTSTR)csValue);
</pre>
And guess what, on appling to 1 UpdateData, 1 Assertion Failure is gone. Still other are their. Thinking to apply the same technique wherever using UpdateData & get rid of the errors & get working done.
For building an application for Win CE device that supports Embedded VC++ & .NET 2003. Is developing in 2003 VC++ much easier than working with eVc++? Asking as I am getting such errors & problems with eVC. Will the same or similar arise with 2003 VC also?
Thanks for all your efforts.
Thanks
Terry
|
|
|
|
|
The error has to do with your Unicode settings. You can use _stscanf() which will work with both MBCS and Unicode.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You can convert from CString to char* in two steps:
CString str1;
char* str2;
...
str2 = (char *) (const char *) str1;
If I have to do this a lot, I define:
#define STOC(X) ((char *) (const char *) (X))
Where STOC stands for "String to char*".
|
|
|
|
|
OOps Alan,
CString csValue;
GetDlgItem(IDC_OpNo_EDIT)->GetWindowText( csValue );
char* str2;
str2 = (char*) (const char*)csValue;
char* stopString;
long l = strtol(str2, &stopString, 9);
int i = (int)l;
: error C2440: 'type cast' : cannot convert from 'class CString' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
Can't understand what is the solution for a simple task.
_stscanf() provided by a helpful member is also not supported by eVC++ in CE platform.
The main reason for doing this conversion is the application throws "Assertion Failure" message followed by "An unsupported operation was attempted" on UpdateData. Their is no scope to debug or find the actual error line. On commenting UpdataData, the error/message doesn't come. So am loking some way to do casting by getting the text via GetWindowText() which by default returns CString only.
I appreciate everybody's help, but still need help to get rid of error messages & make it working one way or the other. Hope to get help.
Thanks
Terry
|
|
|
|