|
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"
|
|
|
|
|
Ganesh_T wrote: I tried with it but was giving whole scrren aftyer printing with reduced size.
Thats cause the printers resolution is more than Screens resolution
heres some sample code
CDC prtDC;
CPrintInfo printInfo;
CSize size;
DOCINFO di;
CSize paper_size;
int xLogPPI = 0;
int yLogPPI = 0;
if( AfxGetApp()->GetPrinterDeviceDefaults(&printInfo.m_pPD->m_pd) )
{
HDC hDC = printInfo.m_pPD->m_pd.hDC;
if (hDC == NULL)
hDC = printInfo.m_pPD->CreatePrinterDC();
if(hDC !=NULL)
{
prtDC.Attach(hDC);
paper_size.cx = prtDC.GetDeviceCaps(HORZSIZE);
paper_size.cy = prtDC.GetDeviceCaps(VERTSIZE);
xLogPPI = prtDC.GetDeviceCaps(LOGPIXELSX);
yLogPPI = prtDC.GetDeviceCaps(LOGPIXELSY);
}
else
{
AfxMessageBox("Can not find printer. Please check installed/default printers.");
return ;
}
}
int scr_xLogPPI = pDC->GetDeviceCaps(LOGPIXELSX);
int scr_yLogPPI = pDC->GetDeviceCaps(LOGPIXELSY);
int paper_width = (int) ((double) paper_size.cx * (double) xLogPPI / 25.4);
int paper_height = (int) ((double) paper_size.cy * (double) yLogPPI / 25.4);
double ratio_x = (double) xLogPPI / (double) scr_xLogPPI;
double ratio_y = (double) yLogPPI / (double) scr_yLogPPI;
CFont *pPrnFont = new CFont();
LOGFONT lf = {0};
lf.lfHeight = -14 * ratio_x;
lf.lfWeight = FW_NORMAL;
_tcscpy(lf.lfFaceName,"Times new roman");
pPrnFont->CreateFontIndirect(&lf);
..
..
..
you need to multiply everything with ratio_x and ratio_y so that everythings printed like it is diplayed on the screen
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."
|
|
|
|
|
I want to use only SDK. no mfc classes. I haveposted the code in my reply to whitesky
"A winner is not one who never fails...but the one who never quits"
-- modified at 4:41 Tuesday 11th July, 2006
|
|
|
|
|
Ganesh_T wrote: I want to use only SDK. no mfc classes. I haveposted the code in my reply to whitesky
Ok Ganesh listen up, The printer resolution is far more than screen's resolution.
So you need to calculate the number of times Printer resolution is greater than Screen's
So get printers Resolution use
int xPrnRes = GetDeviceCaps(hPrinterDC,LOGPIXELSX);
int yPrnRes = GetDeviceCaps(hPrinterDC,LOGPIXELSY);
Get Screens Res
int xScrnRes = GetDeviceCaps(hScreenDC,LOGPIXELSX);
int yScrnRes = GetDeviceCaps(hScreenDC,LOGPIXELSY);
Get Ratio
double ratio_x = (double)xPrnRes/(double)xScrnRes;
double ratio_y = (double)yPrnRes/(double)yScrnRes;
ok so if you have an image of say 100x100 px on screen and you want to print it the destination image will be of 100*ratio_x and 100*ratio_y
so instead of using BitBlt you have to use StretchBlt to stretch the Bitmap
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."
|
|
|
|
|
Hi all,
can anyone tell me about how to detect the frame change in the video file?
Thanks in advance.
Regards,
Ram
|
|
|
|
|
a treectrl such as:
[-]Root1
| |_Lay1Item1
| |_Lay1Item2
| [-]Lay1Item3
| |_Lay2Item1
| |_BB
+Root2
1>.how to get the item handle by its name/string?
2>.how to know the item stay at which lay? for example: Lay1Item1 stay at lay 1, root is 0,BB is lay 2
|
|
|
|
|
(1>.) See GetNextItem(...);
whitesky
|
|
|
|
|
1>.how to get the item handle by its name/string?
->I guess you cannot, what if two nodes having same name? Instead try using GetItem and GetNextitem function.
2>.how to know the item stay at which lay? for example: Lay1Item1 stay at lay 1, root is 0,BB is lay 2
-> SetItemData may help.
Regards
Abhishake Lahare
|
|
|
|
|
thank you for your quick reply.
about 2> in fact, I'v used SetItemData for manage the handle of MDI docs.....
what I want is: aplly different doc template for different lay of item related Doc
|
|
|
|
|
hai every one
i have created one class it contains one big window
and i added some small node(it is also window) to that window.
then when i move the small node on big window
that moving part is changing the color
can any one help me
B.LakshmipathiRao
|
|
|
|
|
i'm not getting ur question, can u give some more information.
how u r moving the smaller windows by code or my mouse?
|
|
|
|
|
Silly question, had a lok in the MSDN but could not find any thing that satisfied my curiosity, how long can a command line be? I´m asking because I am passing a path to a file,plus an SQL query to an external process (using create process), so can I expect any problems regarding a very long SQL query...
Thanks in advance
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
from stdlib.h on VS.NET
/*
* Sizes for buffers used by the _makepath() and _splitpath() functions.
* note that the sizes include space for 0-terminator
*/
#define _MAX_PATH 260 /* max. length of full pathname */
#define _MAX_DRIVE 3 /* max. length of drive component */
#define _MAX_DIR 256 /* max. length of path component */
#define _MAX_FNAME 256 /* max. length of file name component */
#define _MAX_EXT 256 /* max. length of extension component */
Hope these help
Regards
Abhishake Lahare
|
|
|
|
|
The maximum command line length for the CreateProcess function is 32767 characters
More Info here (Old New thing blog)[^]
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."
|
|
|
|
|
Tanks monty, with that mayn characters, I think I´m on the safe side
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
how to get syetem ip addres in an dialog box
i use ipadress control for that
but can somebody tell me wat code i write on a button to get ip address of the sytem
Ashish Dogra
MCA
Noida
|
|
|
|
|
gethostname() for getting name of system and then call
gethostbyname()
See MSDN for more help on these function
Regards
Abhishake Lahare
|
|
|
|
|
thanks
but can you tell me what are parameters in the gethostname()
as a code to help me
Ashish Dogra
MCA
Noida
|
|
|
|
|