|
It should work, and the toolbar responds that something is selected, but there is no selection and the edit control refuses to accept any messages. The cut, copy, and paste features in my program refuse to work after a search. I've never seen this problem before.
-- Steve
|
|
|
|
|
Well,
while working on a class i am facing a really bad problem! well, i just cant get it!
i just run the following code
<br />
BOOL COpenGLWindow::CreateOpenGLWindow(RECT Rect,char* WindowCaption,bool Fullscreen,int Bits,UINT ExStyle,UINT Style,HWND Parent)<br />
{<br />
WNDCLASS WndClass;<br />
WndClass.style=CS_VREDRAW|CS_HREDRAW|CS_OWNDC;<br />
WndClass.lpfnWndProc=OpenGLWndProc;<br />
WndClass.cbClsExtra=0;<br />
WndClass.cbWndExtra=0;<br />
WndClass.hInstance=GetInstHandle();<br />
WndClass.hIcon=::LoadIcon(NULL,IDI_WINLOGO);<br />
WndClass.hCursor=::LoadCursor(NULL,IDC_ARROW);<br />
WndClass.hbrBackground=0;<br />
WndClass.lpszMenuName=0;<br />
WndClass.lpszClassName="OpenGLClass";<br />
if(!RegisterClass(&WndClass))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
bool ShowWnd=(Style&WS_VISIBLE);<br />
Style|=~WS_VISIBLE;<br />
if(!(hWnd=CreateWindowEx(ExStyle,"OpenGLClass",WindowCaption,Style,Rect.left,Rect.top,Rect.right-Rect.left,Rect.bottom-Rect.top,Parent,(HMENU)NULL,GetInstHandle(),NULL)))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!(hDC=GetDC()))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
PIXELFORMATDESCRIPTOR pfd=<br />
{<br />
sizeof(PIXELFORMATDESCRIPTOR),<br />
1,<br />
PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,<br />
PFD_TYPE_RGBA,<br />
Bits,<br />
0,0,0,0,0,0,0,0,0,0,0,0,0,<br />
24,<br />
0,0,0,0,0,0,0<br />
};<br />
int PixelFormat;<br />
if(!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!SetPixelFormat(hDC,PixelFormat,&pfd))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!(hRC=wglCreateContext(hDC)))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(!wglMakeCurrent(hDC,hRC))<br />
{<br />
OutputDebugString();<br />
return FALSE;<br />
}<br />
if(ShowWnd)<br />
{<br />
ShowWindow(hWnd,SW_SHOW);<br />
SetForegroundWindow(hWnd);<br />
SetFocus(hWnd);<br />
}<br />
return TRUE;<br />
}<br />
and the call to CreateWindowEx Failes ! GetLastError() prints INvalid Window Handle.?!?!?!?
well the call bieing made to this function is as follows:
<br />
CreateOpenGLWindow(Rect,"Mine",false,16,WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,WS_POPUPWINDOW,NULL);<br />
WEll i m in serious trouble so please help as soon as possible!
shoaib.
Doesn't Window Really Sucks!
|
|
|
|
|
Hi
My SDI program uses a CFormView derived class as View.I would like to know how i could change the view.What I mean is that when I click a button or a menu bar then I should be able to change the default view(which is a dialog) to another view(another dialog).Please Help
God is Love
|
|
|
|
|
here is the code using which u can chnage the view dynamically. i am assuming that u want the same Docuemnt to be associated with all views.
<br />
<br />
#define FIRST_VIEW 1<br />
#define SECOND_VIEW 2<br />
#define THIRD_VIEW 3<br />
<br />
<br />
void SelectView(UINT ViewID)<br />
{<br />
<br />
CView* pOld=GetActiveView();<br />
<br />
CView* pNew=(CView*) GetDlgItem(ViewID);<br />
<br />
if(pNew==NULL)<br />
{<br />
switch(ViewID)<br />
{<br />
case SECOND_VIEW:<br />
pNew=(CView*) new CSecondViews;<br />
break;<br />
<br />
case THIRD_VIEW:<br />
pNew=(CView*) new CThirdView;<br />
break;<br />
default:<br />
<br />
AfxMessageBox("Invalid ID");<br />
}<br />
<br />
<br />
<br />
<br />
CCreateContext context;<br />
context.m_pCurrentDoc=pOld->GetDocument();<br />
<br />
pNew->Create(NULL,NULL,0L,CFrameWnd::rectDefault,this,ViewID,&context);<br />
pNew->OnInitialUpdate();<br />
<br />
}<br />
<br />
SetActiveView(pNew);<br />
pOld->ShowWindow(SW_HIDE);<br />
pNew->ShowWindow(SW_SHOW);<br />
pOld->SetDlgCtrlID(m_CurrentViewID);<br />
pNew->SetDlgCtrlID(AFX_IDW_PANE_FIRST);<br />
m_CurrentViewID=ViewID;<br />
<br />
CDBase1Doc* pDoc=(CDBase1Doc*)GetActiveDocument ();<br />
pDoc->AddView(pNew);<br />
pDoc->RemoveView(pOld);<br />
<br />
RecalcLayout();<br />
}<br />
<br />
i hope this helps!!<br />
<br />
cheers!! ;)<br />
<br />
<br />
<br />
Muhammad Shoaib Khan<br />
http:
|
|
|
|
|
hi JaisonCodeMan!!
here is the code using which u can chnage the view dynamically. i am assuming that u want the same Docuemnt to be associated with all views.
<br />
<br />
#define FIRST_VIEW 1<br />
#define SECOND_VIEW 2<br />
#define THIRD_VIEW 3<br />
<br />
<br />
void SelectView(UINT ViewID)<br />
{<br />
<br />
CView* pOld=GetActiveView();<br />
<br />
CView* pNew=(CView*) GetDlgItem(ViewID);<br />
<br />
if(pNew==NULL)<br />
{<br />
switch(ViewID)<br />
{<br />
case SECOND_VIEW:<br />
pNew=(CView*) new CSecondViews;<br />
break;<br />
<br />
case THIRD_VIEW:<br />
pNew=(CView*) new CThirdView;<br />
break;<br />
default:<br />
<br />
AfxMessageBox("Invalid ID");<br />
}<br />
<br />
<br />
<br />
<br />
CCreateContext context;<br />
context.m_pCurrentDoc=pOld->GetDocument();<br />
<br />
pNew->Create(NULL,NULL,0L,CFrameWnd::rectDefault,this,ViewID,&context);<br />
pNew->OnInitialUpdate();<br />
<br />
}<br />
<br />
SetActiveView(pNew);<br />
pOld->ShowWindow(SW_HIDE);<br />
pNew->ShowWindow(SW_SHOW);<br />
pOld->SetDlgCtrlID(m_CurrentViewID);<br />
pNew->SetDlgCtrlID(AFX_IDW_PANE_FIRST);<br />
m_CurrentViewID=ViewID;<br />
<br />
CDBase1Doc* pDoc=(CDBase1Doc*)GetActiveDocument ();<br />
pDoc->AddView(pNew);<br />
pDoc->RemoveView(pOld);<br />
<br />
RecalcLayout();<br />
}<br />
i hope this helps!!
cheers!!
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
Hi
Thnaks for the reply Actually I made a function as you ahd mentioned in the mainfrm.cpp in my project and then called that function when i click on a amenu button.But it gave me an exception.Doesnt this function expect me to pass the value fo the diaog as mentione in the resource.h file??Also do i have to make a seperate class for each dialog that I want to make as the view of a document.or can i call any dialog.Please help
God is Love
|
|
|
|
|
JaisonCodeMan wrote:
Doesnt this function expect me to pass the value fo the diaog as mentione in the resource.h file??
The function which i haveshown expects only the no of View which u want to be there.. forexample FIRST_VIEW or what so ever it is...no it is not the identifier of the dialog as mentioned in resource.h.. it isjust the constant like FIRST_VIEW or SECOND_VIEW which ihave declared myself..
JaisonCodeMan wrote:
Doesnt this function expect me to pass the value fo the diaog as mentione in the resource.h file??
yes u need to have seprerate class for each dialog which u want to make as view of document.
cheers
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
how i can change the title of the application ?
|
|
|
|
|
simple!! SetWindowText()
cheers
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
If you want to change the title of an application that uses the Document/view framework then you will have to override PreCreateWindow and set the style to eliminate the WS_CAPTION property otherwise MFC automatically updates the application title to the file name which can be very frustrating!
See mike dunn's C++ FAQ here[^]
My world tour
What I do now..
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
i want to monitor for all incoming and outgoing TCP conenctions on some PC. which APIs to use?
NetMon apis?
or someone having experiecne in this plz guide me!!
Thanx
Shoaib
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
Is there a difference between this:
bool foo(int& a);
and this:
bool foo(int &a);
Thanks.
|
|
|
|
|
To you, the preprocessor, or the compiler? Where you put spaces, and how many you put, is irrelevant to the compiler as the preprocessor removes them all before sending the tokens to the compiler.
Take something like:
#include < stdio.h >
int main( int argc, char **argv )
{
printf("Hello World!\n");
return 0;
} You could have just as easily written it as:
#include < stdio.h >int main( int argc, char **argv ){printf("Hello World!\n");return 0;}
The compiler wouldn't have cared.
|
|
|
|
|
No, however int& is preferable because it makes it clear that the type of "a" is "int&"
Yes, you can start a religious argument over this issue. I don't care. I'm right.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Michael Dunn wrote:
Ericahist
Excellent! I've finally been able to increase my "Pictures of Erica" collection from a measy two to....six. w00t! I suppose six is better than nothing though!
Thanks!
(been an Erica fan since back the GoogleFight of Erica (yeah!) vs Britney (boo! hiss!)) <insert link to the aforementioned post>
I prefer to wear gloves when using it, but that's merely a matter of personal hygiene
[Roger Wright on VB]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
[Rich Cook]
|
|
|
|
|
I am working on a program where I keep background textures in a separate DLL (for simple upgrade possibilities).
I use LoadBitmap in the DLL and I export the pointer to the asociated CBitmap to the application.
Everything works fine, except that refresh is quite slow now.
Does anyone know/recognize this behaviour , or did I do something else wrong?
If someone has a clue and solution, please let me know.
Bert....
|
|
|
|
|
you can load resource in the application directly instead of loading in
dlls.
when you load resource in the application after load some dlls.the system will
look for the resource not only in the application but also in dlls it has loaded.
i hope it works well...
gucy
|
|
|
|
|
WEll, I have been using Borland C++ Builder most of my life, and it always made GUI design a breeze.
But, now I'm using VC++; I've used it before when writing, say, DLLs, so it hasnt been a problem; however, now that I'm designing a GUI, its causing me lots of headaches.
For instance, I only now just found that the filetypes that it looks for when doing, say, file->open, is in resource string table. Or rather, thats what it lists for captions at least, not necessarily where its actually using for the filter.
So, I went and changed the caption - and, of course, its just the caption, and not the filter. So, I've been digging to see where the wizard that created my project is actually saving the filter for file-opening, as I want to add more filetypes to its initial filter.
Meanwhile, I'm also curious, if I wanted to do so, I do I add menus and toolbars to children of the parent window in a MDI project?
As I've been a developer using Borland, I've gotten spoiled with GUI Development
James A Beggs
American Quarter Horse Association Manager of Product Development
|
|
|
|
|
Hi there, I am having trouble with my dialogues using the cross X in the corner of my dialogue doesn't seem to call PostNcDestroy where I perform clean up of the object. I was expecting the WM_CLOSE message to be generated which calls the default DestroyWindow.
Can anyone explain why it is not being called?
Andy
|
|
|
|
|
Interesting. I have a modeless dialog I use in a little app that simply shows a progress bar while the app is running. When I click the 'X', it indeed calls the dialog's PostNcDestroy() function.
|
|
|
|
|
I don't think it is called in modal dialogs.
John
|
|
|
|
|
I don't understand it, I stepped through some of the example code in Nishants tutorial and closing the dialogue with the X definitely calls PostNcDestroy, however it doesn't in mine, despite the fact that clicking the X sends the WM_CLOSE message, which I think should call destroy window. I'm confused, the only difference I can see in my code is that I call ShowWindow in the constructor of my dialogue, and not in the external code. ??
Andy
Still confused
|
|
|
|
|
Is your dialog modeless then?
John
|
|
|
|
|
It's definetly modeless, I create a new dialogue like this
if(!m_pDlgComms)
{
m_pDlgComms = new CCommsDlg(this);
etc
which is then constructed like this
CCommsDlg::CCommsDlg(CWnd* pParent )
: CDialog(CCommsDlg::IDD, pParent)
{
m_sCommsInput = _T("");
m_sCommsOutput = _T("");
if (Create(CCommsDlg::IDD, pParent))
{
m_pParent = pParent;
ShowWindow(SW_SHOW);
}
}
and here is the PostNcDestroy which is called whenever I force a destroy window using a button for example
void CCommsDlg::PostNcDestroy()
{
CDialog::PostNcDestroy();
if(m_pParent)
{
((CBuggycontrolappView*)m_pParent)->m_pDlgComms = NULL;
((CBuggycontrolappView*)m_pParent)->m_nCommsToggleState = 0;
}
delete this;
}
but not when I use the cross. Even though there is a WM_CLOSE message
Andy
|
|
|
|
|
Ok, I understand your problem but I have not seen this in the past. Do you have code for OnCancel() ? Destroying the window with the X button should call OnCancel().
John
|
|
|
|
|