|
|
eusto wrote: ShowWindow
I am surprised. Then how is it being displayed as a modal dialog. Are you able to interact with the parent window.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I'm able to interact with the parent window..in fact it's just as if it weren't there. I can push buttons and stuff on views behind it...It's just that it is drawn on top of all other modeless windows. It's quite odd..try it, you'll see. Just create a MDI project, add in a dialog, add a member to that dialog to your mainframe class and call:
VERIFY(pMainFrame->m_InitialDlg.Create(CInitialDlg::IDD, pMainFrame));
VERIFY(pMainFrame->m_InitialDlg.SetWindowPos(&wndBottom, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE));
in OnCreate method of the MainFrame class
|
|
|
|
|
eusto wrote: VERIFY(pMainFrame->m_InitialDlg.SetWindowPos(&wndBottom, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE));
What about simple ShowWindow() Is that of any use.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
It's actually the same thing. SetWindowPos gives more options. I guess i could play with showwindow(sw_show)/showwindow(sw_hide) depending wether or not there are open documents but that's not a nice thing.
|
|
|
|
|
eusto wrote: VERIFY(pMainFrame->m_InitialDlg.Create(CInitialDlg::IDD, pMainFrame ));
This is the problem I guess. You are setting the parent to pMainFrame . Hence it stays on top of the frame. Give NULL and it will go behind.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Ok, now my code looks like this:
VERIFY(pMainFrame->m_InitalDlg.Create(CInitialDlg::IDD, NULL));
pMainFrame->m_InitalDlg.ShowWindow(SW_SHOW);
It's still the same thing. Actually now i can't even press the buttons on m_InitialDlg.
This is the dialog's style:
DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CONTROL | DS_CENTER | WS_CHILD
|
|
|
|
|
eusto wrote: | WS_CHILD
Why is WS_CHILD given for a dialog that you want to be popup. . Lol make it WS_POPUP .
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Thanks for your help man. It's still not working though . Have you done this? Are you sure it will eventually work this way?
|
|
|
|
|
Do i need to call repaint or something anywere? If i set style to popup, it becomes visible when the user presses a button in that area of the main frame( Even though another child window is opened)
|
|
|
|
|
eusto wrote: VERIFY(pMainFrame->m_InitialDlg.Create(CInitialDlg::IDD, pMainFrame ));
Instead of pMainFrame give m_InitialDialog.GetDesktopWindow().
i.e
VERIFY(pMainFrame->m_InitialDlg.Create(CInitialDlg::IDD, m_InitialDialog.GetDesktopWindow()));
I did a small sample and this worked...
static CAboutDlg dlg;
if( dlg.m_hWnd == NULL )
dlg.Create( IDD_ABOUTBOX,dlg.GetDesktopWindow());
dlg.ShowWindow(SW_SHOW);
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Thanks...I forgot about GetDesktopWindow() ..what was i thinking?
Thanks
|
|
|
|
|
Can't draw CString string with DrawString(GDI+)
CString str=_T("test string");
FontFamily fontFamily(L"Times New Roman");
Font font(&fontFamily, 24, FontStyleRegular, UnitPixel);
PointF pointF(30.0f, 10.0f);
SolidBrush solidBrush(Color(255, 0, 0, 255));
graphics.DrawString(str.GetBuffer(), -1, &font, pointF, &solidBrush);
|
|
|
|
|
DrawString will take WCHAR* as its first argument, CString::GetBuffer() won't workout. Try using WCHAR* instead str.GetBuffer()
|
|
|
|
|
There's no need to use GetBuffer , you can simply pass the CString object, if it's the right width. I suspect you're compiling without UNICODE defined, so your CString is actually a CStringA , which does not have a conversion operator to const WCHAR* . It stores byte-oriented national character set characters. GDI+ expects UTF-16 Unicode characters. You need to either store your strings in this format, or convert them when you need to use them.
Unless you want compatibility with Windows 9x, the easiest thing to do is to simply define UNICODE and _UNICODE , or select the 'Unicode' configuration if you already have one. You need to define both macros because the Windows headers use UNICODE while the C run-time uses _UNICODE . This forces all CString objects to be UTF-16 Unicode. You'll have to fix any compile errors you get here, where you've used a string not wrapped in _T() .
Slightly more difficult is to store any strings you want to display on screen in the correct format. Here you should consider using CStringW objects (I'm assuming you're using at least MFC 7.0 from Visual Studio .NET 2002, rather than MFC 6.0). You can construct a CStringW from byte-oriented national character set data (char* ). You can convert at the point of use if necessary. Using CStringW is slightly more straightforward than trying to use the MultiByteToWideChar API directly.
If explicitly using the wchar_t , WCHAR or CStringW datatypes, you should use the L"" syntax to specify your string literals, rather than _T() . Only use _T() for values that should change format depending on whether _UNICODE is defined.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
CPropertySheet properties(_T("вфыавав"), this, 0);//error C2664: 'CPropertySheet::CPropertySheet(UINT,CWnd *,UINT)' : cannot convert parameter 1 from 'const wchar_t [13]' to 'UINT'
??? but CPropertySheet have constructor with LPCTSTR as the 1st parameter
explicit CPropertySheet(
LPCTSTR pszCaption,
CWnd* pParentWnd = NULL,
UINT iSelectPage = 0
);
|
|
|
|
|
Based on your other question I'd say you probably have _UNICODE defined (which causes _T("") to become L"" ) but not UNICODE , which causes LPCTSTR to become LPCWSTR rather than LPCSTR .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hello, I want to add a new font to my project but I dont know how?
I downloaded a program and made my font MyFont.ftw and I want to add it,how can I add it to my project and use it in the Static Text.
SnaidiS(Semion)
|
|
|
|
|
Not sure what you mean but you can change the Static font like this
CFont *pNewFont = new CFont;
LOGFONT lf = { 0 };
lf.lfHeight = -12;
lf.lfWeight = FW_LIGHT;
_tcscpy(lf.lfFaceName,_T("Tahoma"));
pNewFont->CreateFontIndirect(&lf);
//After the Static control is created
//Typically in InitDialog functions
GetDlgItem(IDC_STATIC_TEXT)->SetFont(pNewFont);
//Don't forget to Delete the font in OnDestroy
delete pNewFont;
Hope it helps
You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!"
Only kings, presidents, editors, and people with tapeworms have the right to use the editorial "we."
|
|
|
|
|
OK! Thank you a lot!!
SnaidiS(Semion)
|
|
|
|
|
I am facing the problem in printing document. I haev craeted the WIn32 Apllicatio and then in WM_PAINT I amdraing the ellipse. Now I want to printwhatever I see on client area.
I tried with it but was giving whole scrren aftyer printing with reduced size.
I need it in Win32.
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
Do you want to prin your shapes did you saw PRINTDLG and StartDoc
whitesky
|
|
|
|
|
I Have seen ...
I need whatever is there in CLient area to be printed....I have written the sample code here:
<br />
void PrintMyPage(HWND hWndMain,HDC hClientDC) <br />
{ <br />
<br />
try<br />
{<br />
DOCINFO lpdi; <br />
<br />
lpdi.cbSize = sizeof( DOCINFO ); <br />
lpdi.lpszDocName = _T( "ReadMe.txt" ); <br />
lpdi.lpszOutput = NULL; <br />
lpdi.lpszDatatype = _T("RAW"); <br />
lpdi.fwType = 0;<br />
<br />
<br />
MessageBox(NULL,_T("Before CreateDC"),_T("Step by Step"),MB_OK);<br />
<br />
<br />
HDC hPrinterDC = CreateDC(_T("HP LaserJet 1020"),_T("HPLaserJ"),NULL,0); <br />
<br />
if(!hPrinterDC)<br />
{<br />
TCHAR szMessage[256];<br />
wsprintf(szMessage,_T("CreateDC Failed, Last Error:%d"),GetLastError());<br />
MessageBox(NULL,szMessage,_T("Error"),MB_OK);<br />
return;<br />
} <br />
<br />
<br />
if(!StartDoc(hPrinterDC, &lpdi))<br />
{<br />
MessageBox(NULL,_T("StartDoc Failed"),_T("Error"),MB_OK);<br />
return;<br />
}<br />
<br />
if(!StartPage(hPrinterDC))<br />
{<br />
MessageBox(NULL,_T("StartPage Failed"),_T("Error"),MB_OK);<br />
return;<br />
} <br />
<br />
int xPage,yPage;<br />
<br />
xPage = GetDeviceCaps(hPrinterDC,HORZRES);<br />
yPage = GetDeviceCaps(hPrinterDC,VERTRES); <br />
<br />
SetMapMode (hPrinterDC, MM_ISOTROPIC) ;<br />
SetWindowExtEx (hPrinterDC, 1000, 1000, NULL) ;<br />
SetViewportExtEx (hPrinterDC, xPage / 2, -yPage / 2, NULL) ;<br />
SetViewportOrgEx (hPrinterDC, xPage / 2, yPage / 2, NULL) ;<br />
<br />
<br />
HDC hCompatibleDC;<br />
<br />
hCompatibleDC = CreateCompatibleDC(hClientDC);<br />
<br />
RECT rt;<br />
GetClientRect(hWndMain,&rt);<br />
<br />
HBITMAP hbmScreen = CreateCompatibleBitmap(hClientDC,<br />
GetDeviceCaps(hClientDC,HORZRES), <br />
GetDeviceCaps(hClientDC,VERTRES)); <br />
SelectObject(hCompatibleDC, hbmScreen);<br />
<br />
<br />
HDC tempDC = CreateCompatibleDC(NULL);<br />
SelectObject(tempDC,hbmScreen);<br />
BITMAP bmp;<br />
GetObject(hbmScreen,sizeof(bmp),&bmp);<br />
<br />
<br />
<br />
if(!::BitBlt(hPrinterDC,0,0, GetDeviceCaps(hCompatibleDC,HORZRES), GetDeviceCaps(hCompatibleDC,VERTRES),hCompatibleDC,0, 0,SRCCOPY))<br />
{<br />
TCHAR szMessage[256];<br />
wsprintf(szMessage,_T("BitBlt failed, Last Error:%d"),GetLastError());<br />
MessageBox(NULL,szMessage,_T("Error"),MB_OK);<br />
return;<br />
}<br />
<br />
<br />
<br />
if(!EndPage(hPrinterDC))<br />
{<br />
MessageBox(NULL,_T("EndPage Failed"),_T("Error"),MB_OK);<br />
return;<br />
}<br />
<br />
if(!EndDoc(hPrinterDC))<br />
{<br />
MessageBox(NULL,_T("EndDoc Failed"),_T("Error"),MB_OK);<br />
return;<br />
} <br />
<br />
MessageBox(NULL,_T("Success"),_T("Success"),MB_OK);<br />
}<br />
catch(...)<br />
{<br />
MessageBox(NULL,_T("Error"),_T("Error"),MB_OK);<br />
}<br />
} <br />
Where I am going wrong......
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|
I insert lines to this code but check your code i used PrintDlg and
use from pd.hDC instead CreateDC and i cant find a ellipse in your code
but when you run this code you see a ellipse almost in center
<br />
void PrintMyPage(HWND hWndMain,HDC hClientDC) <br />
{ <br />
<br />
try<br />
{<br />
DOCINFO lpdi; <br />
<br />
lpdi.cbSize = sizeof( DOCINFO ); <br />
lpdi.lpszDocName = _T( "ReadMe.txt" ); <br />
lpdi.lpszOutput = NULL; <br />
<br />
<br />
<br />
<br />
<br />
<br />
PRINTDLG pd;<br />
memset((void *)&pd, 0,sizeof(PRINTDLG));<br />
pd.lStructSize = sizeof(PRINTDLG);<br />
pd.hwndOwner = hWndMain;<br />
pd.Flags =PD_RETURNDC|PD_ENABLESETUPTEMPLATE;<br />
pd.hInstance = NULL;<br />
pd.nMaxPage=1;<br />
pd.nMinPage=1;<br />
pd.nCopies=1;<br />
pd.hDevMode=0;<br />
pd.nFromPage=1;<br />
pd.nToPage=1;<br />
PrintDlg(&pd);<br />
HDC hPrinterDC = pd.hDC;<br />
if(!hPrinterDC)<br />
{<br />
TCHAR szMessage[256];<br />
wsprintf(szMessage,_T("CreateDC Failed, Last Error:%d"),GetLastError());<br />
MessageBox(NULL,szMessage,_T("Error"),MB_OK);<br />
return;<br />
} <br />
<br />
<br />
if(!StartDoc(hPrinterDC, &lpdi))<br />
{<br />
MessageBox(NULL,_T("StartDoc Failed"),_T("Error"),MB_OK);<br />
return;<br />
}<br />
<br />
if(!StartPage(hPrinterDC))<br />
{<br />
MessageBox(NULL,_T("StartPage Failed"),_T("Error"),MB_OK);<br />
return;<br />
} <br />
<br />
int xPage,yPage;<br />
<br />
xPage = GetDeviceCaps(pd.hDC,HORZRES);<br />
yPage = GetDeviceCaps(pd.hDC,VERTRES); <br />
<br />
SetMapMode (pd.hDC, MM_ISOTROPIC) ;<br />
SetWindowExtEx (pd.hDC, 1000, 1000, NULL) ;<br />
SetViewportExtEx (pd.hDC, xPage / 2, -yPage / 2, NULL) ;<br />
SetViewportOrgEx (pd.hDC, xPage / 2, yPage / 2, NULL) ;<br />
<br />
<br />
HDC hCompatibleDC;<br />
<br />
hCompatibleDC = CreateCompatibleDC(hClientDC);<br />
<br />
<br />
RECT rt;<br />
GetClientRect(hWndMain,&rt);<br />
<br />
HBITMAP hbmScreen = CreateCompatibleBitmap(hClientDC,GetDeviceCaps(hClientDC,HORZRES), GetDeviceCaps(hClientDC,VERTRES)); <br />
SelectObject(hCompatibleDC, hbmScreen);<br />
<br />
<br />
HDC tempDC = CreateCompatibleDC(NULL);<br />
SelectObject(tempDC,hbmScreen);<br />
BITMAP bmp;<br />
GetObject(hbmScreen,sizeof(bmp),&bmp);<br />
<br />
Ellipse(pd.hDC,100,100,400,400);<br />
<br />
<br />
<br />
<br />
<br />
if(!EndPage(pd.hDC))<br />
{<br />
MessageBox(NULL,_T("EndPage Failed"),_T("Error"),MB_OK);<br />
return;<br />
}<br />
<br />
if(!EndDoc(hPrinterDC))<br />
{<br />
MessageBox(NULL,_T("EndDoc Failed"),_T("Error"),MB_OK);<br />
return;<br />
} <br />
<br />
MessageBox(NULL,_T("Success"),_T("Success"),MB_OK);<br />
}<br />
catch(...)<br />
{<br />
MessageBox(NULL,_T("Error"),_T("Error"),MB_OK);<br />
}<br />
} <br />
whitesky
|
|
|
|
|
I have the ellipse created on WM_PAINT.
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
::Ellipse(hdc,100,100,500,500);
RECT rect;
rect.left = 200;
rect.top = 200;
rect.right = 400;
rect.bottom = 400;
::DrawText(hdc,_T("I am the best"),(int)strlen(_T("I am the best")),&rect,DT_CENTER);
EndPaint(hWnd, &ps);
break;
and on the menu click:
case IDM_MENU1:
hClientDC = GetDC(hWnd);
PrintSelected(hWnd,hClientDC);
break;
I don't want directly to draw ont print dc. First I want to take the handel of my Client DC such taht whatever is drawn on the client are shouldbe printed on page
"A winner is not one who never fails...but the one who never quits"
|
|
|
|
|