|
hi all,
when i switch from one CFormView to Another CFormView, I am observing that my menu items for the second form are Disabled. I cant Understand why this is Happen when i switch from one view to another.
//---------Code -----------------------------------//
void CMainFrame::SwitchView()
{
CView *pOldView;
CView *pNewView;
pOldView = GetActiveView();
if (m_pCFirstView == NULL)
m_pCFirstView = pOldView;
if (m_pCSecondView == NULL)
{
CRuntimeClass *pCR = RUNTIME_CLASS(CSecondView);
m_pCSecondView = static_cast<cview*>(pCR->CreateObject());
m_pCSecondView->Create(NULL,NULL,AFX_WS_DEFAULT_VIEW,rectDefault,this,AFX_IDW_PANE_FIRST+1,NULL);
}
if (m_bFirstViewActive)
pNewView = m_pCSecondView;
else
pNewView = m_pCFirstView;
int nChildId = pNewView->GetDlgCtrlID();
pNewView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pOldView->SetDlgCtrlID(nChildId);
CDocument *pDoc = pOldView->GetDocument();
pDoc->AddView(pNewView);
pDoc->RemoveView(pOldView);
SetActiveView(pNewView);
RecalcLayout();
pNewView->ShowWindow(SW_SHOW);
pOldView->ShowWindow(SW_HIDE);
m_bFirstViewActive = !m_bFirstViewActive;
}
//-----------------------------//------------------------------------//
Every thing is Ok but the Menu Items are Enabled when i transform from View to Another View. Please Provide me good Solution.
is there any Custom Command Routing for this.
please help me out.
uday.
-- modified at 7:36 Wednesday 19th July, 2006
|
|
|
|
|
Do you have UI updating defined only in one view, then?
Normally the view will get a crack at updating menu item states. If there's no handler, and no update handler, a menu item will get disabled.
Steve S
Developer for hire
|
|
|
|
|
hi steve,
Should i take Command Handlers in View or CFrameWnd, Shall i take in What order to this Problem.
Please help me out.
uday.
|
|
|
|
|
You can handle commands (and hence UI updating) in any of:
Frame - if you've derived your own frame window
Document - even though it isn't a window!
View - the active one
There is a series of articles in MSJ (now MSDN magazine) which you should still be able to find at the MSDN website, that explain how the routing works in some depth. Essentially, it's up to you as the app designer to determine where the appropriate/correct place for handlers is. For example, handling File/Print would generally be in the document class (since it applies irrespective of the view), whereas edit menu items tend to be managed by the view. If you have multiple views (either SDI switching or MDI) then it is perfectly possible that you have handlers in each view. However, only one of these handlers/UI updates will be called, and it will be the one in the object associated with the active view.
Steve S
Developer for hire
|
|
|
|
|
plz tell me answer for this
i want to know is this code work when i click tab1 on tab control
i try this but not do the work.
void CGouravDlg::OnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CBrush brush;
CDC *pDC;
if(BN_CLICKED(IDC_TAB1))
{
brush.CreateSolidBrush(RGB(100,0,0));
pDC->SetBkColor(RGB(100,0,0));
// m_tab.SendMessage(WM_PAINT,0L,0L);
}
*pResult = 0;
}
Ashish Dogra
MCA
Noida
-- modified at 7:24 Wednesday 19th July, 2006
|
|
|
|
|
I dont know why you ask this question repeated I reply to you in previous thread and you can find your answer in this article(you can derived tabctrl and use from <ocde>WM_PAINT)
whitesky
|
|
|
|
|
Hi all,
I need to convert text from an edit control to double in an MFC application.
I also need to convert a double into a CString to display it in an edit box.
How can i do that ?
Thanx in advance,
Desmo16.
|
|
|
|
|
You can use
For Double to CString
CString Format function
CString to Double
double atof(const char *string );
See msdn once before posting a question
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Its meCString to Double
double atof(const char *string )
If you want error handling use strtod and check return value, errno and end-pointer.
|
|
|
|
|
1.CString to double
use atof()
2. Double to CString.
use CString::Format() funtion.
nave
|
|
|
|
|
|
See
<code>
char *Char;
double Double;
Char = " -1234.56";
Double = atof( Char );
CString str;
str.Format("%lf",Double);
whitesky
|
|
|
|
|
If i've got a char vector ( example: char name[30]),
and i want to convert it into a CString,
is there a way to do that ?
|
|
|
|
|
char name[30] = "hello you";
CString str = name;
char name2[30];
strncpy(name2, str, sizeof(name2));
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-- modified at 11:12 Wednesday 19th July, 2006
|
|
|
|
|
toxcct wrote:
char name[30] = "hello you";
CString str = name;
char name2 = str;
char name[30] = "hello you";
CString str = name;
char name2 = str;
char name2 = str[0]; is fine, or char* name2 = str.GetBuffer() , but not the other.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
toxcct wrote: char name2;
strcpy(name2, str);
That still won't compile. You'd have to write it like so:
char name2;
strcpy(&name2, str);
Which is VERY BAD. Since strcpy doesn't check for proper lengths on the source array, it will just start writing to memory at the address (which is the address of a single character) and keep going until its done. That is, it will overwrite at least 1 character in memory that is not allocated for name2 if str is anything but an empty string. I believe what you wanted to show was:
char name2[30] = {0};
strcpy(name2, str);
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
-- modified at 10:56 Wednesday 19th July, 2006
|
|
|
|
|
oops, i was meaning char[30] , not only char . and to ensure the length of data copied, strncpy() is the function to use...
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Hi,
I load an image and simply display it ..
How can i Zoom on the area of the picture ?!
I can zoom
right now i zoom on the picture with using bigger rect of my source image and just displaying it ...
Is there any technic or special method in GDI+ ?!
I need Faster drawing
|
|
|
|
|
Hi Friends,
How do I find out if the target platform supports 64 bit Arithmetic or not?
I will also like to know about finding if the target platform is Little Endian or Big Endian.
Are ther some compiler switches which help to determine these. The code is mostly C++ code but it needs to be compiled for different platforms.
Thanks in Advance.
Regards.
|
|
|
|
|
Well, VC6++ includes __int64, so you could check
#if defined(_MSC_VER)
#if _MSC_VER >= 1200
// Yup, it's VC6 or later
#endif
#endif
There are different processor type macros, such as _M_IX86 which you can use to determine that it's compiling for X86. There are similar ones supported by (for instance) the ARM compiler for Windows Embedded.
What you need to do is look at the predefined macros like this for each of the compilers you're using for different platforms.
Steve S
Developer for hire
|
|
|
|
|
How do I find out if the target platform supports 64 bit Arithmetic or not
that depends mostly on the compiler. even machines that don't support 64 instructions in hardware can support it in software. ex.: __int64 i; will work wherever MS's C/C++ compiler works.
psychedelic_fur wrote: I will also like to know about finding if the target platform is Little Endian or Big Endian.
int tst=1;
if (((char*)tst)[0])
printf("Low endian");
else
printf("High endian");
Do the chickens have large talons?
|
|
|
|
|
how to read and write in file in case of vs 6.0
|
|
|
|
|
use STL :
std::ifstream and std::ofstream are what you're looking for, in case of C++, fopen() , fread() , fwrite() , fscanf() , fprintf() , fclose() otherwise
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
Hi TOXCCT,
I want to create a cpp file template through MFC application. If i specified the class name( TestClass ) the application will automatically create the file TestClass.cpp with some codes like
#include TestClass.h
.
.
.
TestClass::TestClass()
{
}
.
.
.
someComments...etc.
if i want to do the same method or any other method is there????
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|