|
Dear All,
I have a MDI application and I'm currently trying to programmatically change the active view.
So in sort I have a combo box on my toolbar which list the views currently open.
When I select a different view in this combobox I want that view to come into focus. Basically it should do exactly the same as selecting the view from the 'Window' main menu option.
I have tried sending the WM_MDIACTIVATE message to the main frame but this doesn't seem to work.
Any suggestions would be gratefully received.
Many thanks
Tom
|
|
|
|
|
I would suggest you the MDIActivate member of CMDIFrameWnd class.
I hope it works.
|
|
|
|
|
Hi
Thanks for the suggestion of using MDIActivate, unfortunately this doesn't seem to do trick when I call the following:
pMainFrm->MDIActivate((CWnd*)pView);
Where pView is a pointer to the view I want to activate and bring to the front of all other view windows.
I was wondering if I should be casting here and whether I had used the function correctly.
Thanks
Tom
|
|
|
|
|
I suppose the parameter of MDIActivate should be a frame window (CMDIChildWnd ) which contains your view.
Try this:
CWnd * p = pView->GetParent();
ASSERT_KINDOF(CMDIChildWnd, p);
pMainFrm->MDIActivate(p);
|
|
|
|
|
I wrote the following procedure to activate views programatically. It's a bit specialised, but I hope it might give you some useful clues. The bit underneath the comment "//There is already a View displaying this parent..." activates the view pointed to by pView.
CKernelView* CMainFrame::ActivateView(CModel* pParentModel)
{
CKernelView *pView, *pActiveView;
CWnd* pBar;
CMDIFrameWnd *pFrame;
CMDIChildWnd *pChild;
pBar = GetDlgItem(IDD_NAVIGATOR_BAR);
pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
pActiveView = (CKernelView*)pChild->GetActiveView();
if (pActiveView->m_pParentModel == pParentModel)
pView = pActiveView;
else if (pParentModel->m_pShadow != NULL)
{
pView = pParentModel->m_pShadow->m_pView;
pFrame = (CMDIFrameWnd*)pView->GetParentFrame();
pFrame->ActivateFrame(SW_RESTORE);
}
else if (pBar->IsDlgButtonChecked(IDC_TRACK_NEW))
pView = pParentModel->OpenView(m_pDocViewed, pParentModel->m_PlantFlag);
else
{
pView = pActiveView;
pView->ChangeModel(pParentModel);
}
return pView;
}
Best Regards
Cliff
-- modified at 17:36 Monday 3rd July, 2006
|
|
|
|
|
Hi guys i got stuk in a problem........
i want to read the unicode file with C/C++......
thnx in advance
here is the piece of code
FILE* fp = NULL;
wchar_t* buf = (wchar_t*)malloc(sizeof(wchar_t) * 200);
wchar_t* retbuf = NULL;
if ((fp = fopen("d:/GRCasual.txt", "r")) == NULL) // opens the file
{
return 0;
}
while(!feof(fp))
{
/*fseek(fp,sizeof(char),SEEK_CUR); */
retbuf = fgetws(buf, 200, fp);
}
if( fp )
fclose(fp);
return 0;
Best Rgards
Rocky
|
|
|
|
|
I shall assume you are trying to read a UTF16LE (with BOM) file and I shall also assume you are compiling with UNICODE defined.
FILE* fp = NULL;
wchar_t buf[201];
wchar_t bom;
if ((fp = fopen("c:\\GRCasual.txt", "r")) == NULL)
{
return 0;
}
size_t read = fread(&bom, sizeof(bom), 1, fp);
if(bom == 0xFEFF)
{
while(!feof(fp))
{
read = fread(buf, sizeof(buf[0]), (sizeof(buf) / sizeof(buf[0])) - 1, fp);
buf[read] = '\0';
MessageBox(NULL, buf, L"Text", MB_OK);
}
}
if( fp )
fclose(fp);
return 0;
But i think it would be better to use this instead. If you use the C functions like fopen you can't open files with unicode filenames...
http://www.codeproject.com/file/stdiofileex.asp[^]
|
|
|
|
|
hey dude can u tell me whatz the problem in this code .........
or how can i remove the problem from this code
best regards
Rocky
|
|
|
|
|
Huh? Is there a problem with the code I posted? If you don't describe your problem clearly how can you expect people to bother helping you? You didn't even state what type of unicode file you are reading. UTF8? UTF16? UTF32? Big Endian? Little Endian? With or without BOM?
|
|
|
|
|
After user start windows, user may choose local logon or network logon. when network logon choosed, domain name list is available for user.
My question is how to enumerate domain name list by winapi. I have known how to enumerate domain server name.but I don't know how to get domain name list. could you take a advise?
thank.
bob
|
|
|
|
|
in a project when we design header files for ex. a importbutten.h or sample.h
we start like this
#if !defined(AFX_IMPBUTTON_H__E6F7CDB9_87FB_4CB2_BC6B_3CD7D2DEBC8A__INCLUDED_)
#define AFX_IMPBUTTON_H__E6F7CDB9_87FB_4CB2_BC6B_3CD7D2DEBC8A__INCLUDED_
so how this bracket term is declared, what is pattern my id is
nirmal_ec1984@rediffmail.com
|
|
|
|
|
This is generated by class wizard and the purpose is to have one unique identifier string (probably using date and time info and things like that). So that's why it looks so complicated. But you could simply replace that string with one of yours (anything you want, but it must be unique in your complete project).
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
I have to add a toolbar to my win32 application. Can anyone tell the way to do this , or provide the link to any article about it?
Cyber Friend
|
|
|
|
|
When i resize the dialog, the dialog content are redrawed. However, when the dialog resize, the window is not smoothly move.... how can i make it smoothly???
|
|
|
|
|
How did you resize the window?????
"Dream bigger...Do bigger...Expect smaller"
aji
|
|
|
|
|
i use "this->RedrawWindow(rcDest);"
|
|
|
|
|
y are u using RedrawWindow????????
while u have only the rquirement to resize the window....
try MoveWindow.
BOOL MoveWindow(
HWND hWnd,
int X,
int Y,
int nWidth,
int nHeight,
BOOL bRepaint
);
"Dream bigger...Do bigger...Expect smaller"
aji
|
|
|
|
|
Dear all,
I am developing one application containing propertysheet. I want to validate the data that user enters in property pages.
The problem I am facing is, when user enters wrong data, I validate this data in property page "OnOK" handler and corresponding message is shown to user. But when user clicks OK button on message box, message box as well as propertysheet get closed. I want this propertysheet remain open so that user can correct the wrong data entered.
How to do this?
Thanks in advance.
|
|
|
|
|
Maybe you should do the validation in OnKillActive handler of property page. According to documentation, "override this member function to perform special data validation tasks". You have to display your error box here and then return FALSE if data are invalid.
|
|
|
|
|
thank you very much its working
|
|
|
|
|
If the validation fails, exit the OnOK and do NOT call the OnOK function in the Paerent class. There are better solutions for validation. Each time a field is updated, you should check wheter the information is valid. As long as not all information is valid, you can disable the OK button. Think of handlers like EN_CHANGE (EDIT field) or SELCHANGE (Listbox) etc. I normally add to each dialog a member function to do all validations. It is called each time the user changes anything.
|
|
|
|
|
What i am trying to do is make a console program that gets playlist info from winamp and stores 2 things, the track number and the corresponding track name and stores it into a vector that is a struct with and int and a char defined like this:
struct sIPlaylist
{
char *Name;
int Position;
};
vector <siplaylist> dPlaylist;
The problem that i am having is that after i do a loop and go through the entire playlist and store both values for each song when i try to recall it like this:
Console::WriteLine(dPlaylist.at(a).Name);
no matter what number i put at a the text is always the last song name in the playlist escentially all of the Name part of the vector are the same text. this is how the loop is defined:
void CWinamp::gEntirePlaylist()
{
sIPlaylist tmp; // i think this might be where my problem is but im reseting the values at the beginning of each loop
for(int i=0; i < wInfo.pTotal ; i++) // run the loop until the end of the playlist
{
tmp.Name="";
tmp.Position=i+1;
tmp.Name=gTrackName(i); // gTrackName returns a char * with the song name of playlist track number i
dPlaylist.push_back(tmp); // move the lastest info to the bottom of the vector
}
Console::WriteLine(dPlaylist.size());
Console::Write(dPlaylist.at(222).Position); // this works perfectly
Console::Write(". ");
Console::WriteLine(dPlaylist.at(222).Name);
}
This is the console output:
222. Benny Bennassi .... Whos your daddy
that song isnt actually number 222 but actually number 3111 which is the last song in the playlist.
Im not sure what im missing but i obviously have some part of my code wrong and i would really appreciate any help.
- Corntoe
-- modified at 4:53 Monday 3rd July, 2006
|
|
|
|
|
|
The problem is probably because you don't use the char* correctly. The problem is probably in the function gTrackName but it is difficult to see wihtout seing the code. You cannot simply copy a string into your char array just by using =.
It would be much more efficient if you use the string from the STL also:
struct sIPlaylist
{
std::string Name;
int Position;
};
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
I suppose "char * Name " field of all of your sIPlaylist objects keeps a pointer to a string which is build by gTrackName function. This string is overwritten by each execution of gTrackName function, that’s why you only see the last value.
A solution is to keep the name inside the sIPlaylist structure. You can first define it as
struct sIPlaylist
{
char Name[100];
int Position;
}; and then use string-copy function:
strcpy(tmp.Name, gTrackName(i));
In more elaborated program, you should use dynamic allocation, or better get the assistance of std::string class from STL. In MFC projects, you can use CString class.
I hope it helps.
|
|
|
|