|
you are try func "SetFont" to set font .
e.g
CDialog dlg;
CFont font;
font.CreateFont(...... );
dlg.SetFont(&font);
|
|
|
|
|
note where ive placed the comments in the following code and could you explain the results im getting, thanks.
// Evaluates a given input.
#include <iostream>
#include <conio.h>
using namespace std;
char menu(void);
char command = menu(); // dosent work here
void switchn()
{
char command = menu(); // works ok here
switch ( command )
{
case 'e':
case 'A': cout << "plebs";
break;
case 'j':
case 'B': cout << "flebs";
break;
default: cout << '\a' << flush;
}
getch();
return;
}
char menu(void)
{
char a;
cin >> a;
return a;
}
|
|
|
|
|
Your first location is not in a normally executable region of your source file.
At best, it is executed once when the program starts (to assign a value to the global variable command), but not ever again.
|
|
|
|
|
In an MDI app , if the user maximizes the main frame , how should i resize the view ?
Do this idea work
CMainFrame::OnSize(...)<br />
{<br />
CMDIFrameWnd::OnSize(nType, cx, cy);<br />
<br />
CView *vw = this->GetActiveView();<br />
if(vw){<br />
<br />
}<br />
}
|
|
|
|
|
Check out MoveWindow().
Kuphryn
|
|
|
|
|
I'm trying to create a button on a property sheet (not a property page). Here's what I have for creating the button:
SetWindowPos( &wndTopMost, 200, 100, 700, 500, SWP_SHOWWINDOW );//This is the property sheet window
pWnd = GetParent();
m_btnRead.Create("Button Text Here", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, CRect(10, 50, 690, 490), pWnd, 1);
The button never shows up anywhere, no matter what coordinates I put in.
Am I using CRect incorrectly? Or am I just missing the obvious somewhere?
I do apologize for asking this, but I've never worked with property sheets before and I've always just dropped the buttons onto the dialog where I needed them (yes, I was being lazy).
Any help is appreciated.
|
|
|
|
|
If this code is IN the property sheet, you problem might be with the GetParent() call. You are getting the parent of the PropertySheet, which might very well be the desktop...
Try leaving out the GetParent() call and use this instead. (Keep in mind your child coordinate are relative to upper left corner of property sheet, and not entire screen...)
m_btnRead.Create("Button Text Here", WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON, CRect(10, 50, 690, 490), this, 1);
|
|
|
|
|
Thank you for responding. However...
Blake Miller wrote:
If this code is IN the property sheet, you problem might be with the GetParent() call.
It is indeed in the Property Sheet. I'm trying to create buttons when the Property Sheet is called (or launched).
I tried leaving out the GetParent() call, but still nothing.
The MSDN says that for creating buttons, the parameters should be:
Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );
I'm curious about something here: if I'm not calling GetParent, how exactly would I reference the parent window? "this" doesn't work and, as far as I can tell, there is no variable for it or really any way to reference it since it's a CPropertySheet class and I need a CWnd class for the 4th parameter.
Blake Miller wrote:
Keep in mind your child coordinate are relative to upper left corner of property sheet, and not entire screen...
The width and height of the Property Sheet are: 700 and 500. That's why I put the coordinates at 690 and 490. As far as I can tell, that should put it in the bottom right corner. Or am I misreading it?
|
|
|
|
|
My analysis would eventually lead to what PJ Arends is already telling you (in other messages). I think there is something not quite right in your system.
Anyway, the 'this' of a CPropertyShett will be cast to a CWnd, since the CPropertySheet is derived from a CWnd. That is why I asked if your code was part of a CPropertySheet member function.
|
|
|
|
|
The parent window of the button should be the property sheet. It looks like you are making the button a sibling of the sheet, not a child of the sheet. Also, and I do not know if this is affecting your button creation, but you are using the ID of 1, which is the same as the ID of the OK button which already exists on the sheet.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Thank you for responding.
PJ Arends wrote:
The parent window of the button should be the property sheet. It looks like you are making the button a sibling of the sheet, not a child of the sheet.
Okay, this may be a stupid question, but am I not declaring the parent window as the property sheet? Where am I making it a sibling instead of a child?
I changed the ID, but still nothing.
|
|
|
|
|
Ok, just for the heck of it do this
int CMyPropertySheet::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_MyButton.Create(_T("The Button"),
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
CRect(30, 30, 1024, 768),
this,
ID_MY_BUTTON))
{
ASSERT (FALSE);
return -1;
}
return 0;
} You should now have one huge button that takes up your entire sheet and then some. Now play with the size and position until you get the button where you want it.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Nope; no button.
Could it just be that new buttons can't be created directly onto a property sheet? I would think that they could because you can remove buttons or move them around (which I've done).
What am I missing here?
|
|
|
|
|
Unless the create function failed the button has got to be there. Grab Spy++ and look up your sheet, check out what it's child windows are. Your button has to be there. I tried the code I posted before I submitted it and it worked just fine here.
I am at a loss as to what you are doing wrong, because I use this method to add several buttons and a bitmap to my property sheet.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
According to Spy++, none of the buttons (yours or mine) are there. It lists the other things associated with the property sheet, including the OK and Cancel buttons, but the buttons that I'm trying to create (which includes the code you supplied as a test) aren't there.
This is driving me crazy.
|
|
|
|
|
Place a breakpoint in the OnCreate function just to make sure the code is actually being run. Did you remember to add the ON_WM_CREATE() macro to your message map?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
Did you remember to add the ON_WM_CREATE() macro to your message map?
Yes, I did.
According to the step-through, it is entering OnCreate and moving to the Create line for the button. It is returning 1, but that, according to the message, is success. So, it's saying that it is creating it. I just don't know where it's creating it at since it's not showing up anywhere on the property sheet.
Everything else that I'm doing in OnCreate and OnInit work. Buttons are removed or moved, the menu is added, all of it; everything except creating the buttons.
|
|
|
|
|
Ok, in the debugger check what the value of the button's m_hWnd variable is. Then in Spy++ bring up the window finder dialog (Ctrl + F) and enter that value in the handle edit box. Click Enter. You should now be able to tell which window is the parent of your button, it should be the property sheet, if not what is it?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
According to the debugger, the hWnd of the button is 0x00000000. Spy++ says "specified handle is not vallid". I knew that as soon as I saw it, but I tried it anyway.
So, what's happening here? It's being created (it's returning a non-zero value indicating success), but it doesn't have a valid handle. Is it just being created and then destroyed before getting added to the property sheet?
Any ideas?
|
|
|
|
|
bcemick wrote:
Any ideas?
No, that does not make any sense to me. Create() is returning 1 (success) but the buttons HWND is zero (not a window). I am at a loss.
Just for the heck of it maybe you can try doing a rebuild all, that will sometimes fix weird errors.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Tracing into the MFC source for CButton::Create() we get to this code in CWnd::CreateEx (in Wincore.cpp)
#ifdef _DEBUG
if (hWnd == NULL)
{
TRACE1("Warning: Window creation failed: GetLastError returns 0x%8.8X\n",
GetLastError());
}
#endif
if (!AfxUnhookWindowCreate())
PostNcDestroy();
if (hWnd == NULL)
return FALSE;
ASSERT(hWnd == m_hWnd);
return TRUE; So there is no way that Create will return TRUE (1) if the HWND is NULL (0).
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
So there is no way that Create will return TRUE (1) if the HWND is NULL (0).
I know. That's what was so weird about all of this. I swear that's what was happening. I tried rebuild all and now it's returning a non-NULL handle; the handle is still invalid though.
I tried moving it into another function to see what would happen. I got hWnd handles, but none of them are valid handles according to Spy++. It is still returning 1 (success).
The only thing I can think of is that the button is being created, but it's being destroyed before it can be added to the property sheet (if that makes sense - it sounds better in my head). It's either that or I am missing something so obvious that it would've killed me if it was a snake.
One way or another, I'm going to make this work.
Any help is greatly appreciated (and you've been great so far). If nothing else, it eliminates a possibility.
|
|
|
|
|
One last guess, I am sure you did but I have to ask anyway because I am running out of ideas, did you make your CButton variable a member of your CPropertySheet derived class? I ask this because the only way the button would be destroyed before it is added to the sheet is if your CButton variable is going out of scope and being destroyed that way.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
did you make your CButton variable a member of your CPropertySheet derived class?
ummm....of course I...ummm...you know...umm...
Thank you. I'll go slam my head into a wall repeatedly.
Now I just have to figure out how to get into the right place and then line up those other buttons beside it. Which I will. On my own. So I don't look so incredibly dense.
|
|
|
|
|