|
DavidCrow wrote: It would take all of 10 seconds to change all references from CButton to CMyButton using search/replace in the IDE. You've spent 100 times that just looking for a solution, let alone implementing one.
thats what we call.. a great reply!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hi
i have a problem ,when i changed the font of any simple dialog from property of that dialog i observed the effect,but when i do same think for property page i didn't get the effect,i get the solution by
this->GetDlgItem(id of control)->SetFont(font size);
but i have a lot of controls on my dialog there is any short method.
please reply i wiil be obliged
malik
|
|
|
|
|
Try to put all IDs in an contigous area and make a loop. I mean:
#define IDD_PROPERTY_SHEET 10000
#define IDD_CTRL_BUTTON1 IDD_PROPERTY_SHEET + 1
...
#define IDD_CTRL_EDIT_N IDD_PROPERTY_SHEET + m (from buttons) + n (from edits)
and then use a for:
for (int i = IDD_PROPERTY_SHEET; i <= IDD_CTRL_EDIT_N; i++)
this->GetDlgItem (i)->SetFont (font_size);
Hope it helps
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
in your propertySheet::OnInitDialog() :
CPropertyPage* pPage = GetActivePage ();
ASSERT (pPage);
// change the font for the sheet
ChangeWindowFont(this, &m_font);
// change the font for each page
for (int iCntr = 0; iCntr < GetPageCount (); iCntr++)
{
VERIFY (SetActivePage (iCntr));
CPropertyPage* pPage = GetActivePage ();
ASSERT (pPage);
ChangeWindowFont(pPage, &m_font);
}
VERIFY (SetActivePage (pPage));
void propertySheet::ChangeWindowFont(CWnd* pWnd, CFont *pFont)
{
CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);
while(pChildWnd)
{
pChildWnd->SetFont(pFont, FALSE);
pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
}
}
|
|
|
|
|
Most common controls use the parent's font. Try setting the
font for the page instead of for every control.
Try changing
this->GetDlgItem(id of control)->SetFont(...);
to this
SetFont(...);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
How I can subclass all buttons used in my program.
I know how to do it for one button :
// - m_ctlButton is a CCustomButton for example
m_ctlButton.SubclassDlgItem(IDC_BCANCEL, this);
but I need a way to subclass all buttons in my MFC7 application.
I know there must be a way!
Thanks;)
|
|
|
|
|
Create a class inheriting from the CButton, make the subclassing in that class and use that class all over the program to create button.
Hope you getting me
Thanks,
Anand.
|
|
|
|
|
I have created a class that is derived from CBotton,
I know that I can make all buttons a variable from CMyButton,
But I want to change all my program buttons to CMyButton at once,means not to do it one by one and without declaring a CMyBotton object for all buttons.
I hope you understand what I mean.
Thanks
|
|
|
|
|
Can you try doing a reinterpret_cast for changing the type of the buttons at runtime. Your requirement is not clear but you may however create variables for CButton and use dynamic casting to change the behavior of buttons to what you want.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Try hooking the CreateWindow/CreateWindowEx API
|
|
|
|
|
Hi,
I am trying to display a wide char string to an Edit box. My prject setting is MBCS. Is it possible to display Wchar string in non-unicode project?
If so Please let me know.
For setting unicode font :
CDC *pDC = GetDC();<br />
<br />
LOGFONT lf;<br />
memset(&lf, 0, sizeof(lf)); <br />
lf.lfHeight = MulDiv(12, ::GetDeviceCaps(pDC->m_hDC, LOGPIXELSY), 72);<br />
lf.lfWeight = FW_NORMAL;<br />
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;<br />
_tcscpy(lf.lfFaceName, _T("Lucida Sans Unicode")); <br />
m_font.CreateFontIndirect(&lf);<br />
<br />
m_edit.SetFont(&m_font);
For Displaying text :
wchar_t str[10];<br />
str[0]=0x41;<br />
str[1]=0x42;<br />
str[2]=0x284;<br />
str[3]=0x44;<br />
str[4]=0x45;<br />
str[5]=0x46;<br />
str[6]=0x47;<br />
str[7]=0x48;<br />
str[8]=0x49;<br />
str[9]=0x00;<br />
<br />
::SetWindowTextW(m_edit.m_hWnd,(LPCWSTR)str);
Plz help.
Thanks.
|
|
|
|
|
Yes its possible. but now your trying to set the unciode text in some edit box placed in the resource isnt it. Instead of that use the CreateWindowExW() directly to create the edit box.
wchar_t str[10];
str[0]=0x41;
str[1]=0x42;
str[2]=0x284;
str[3]=0x44;
str[4]=0x45;
str[5]=0x46;
str[6]=0x47;
str[7]=0x48;
str[8]=0x49;
str[9]=0x00;
HWND hEdit = CreateWindowExW( 0, L"Edit", str, WS_CHILD|WS_VISIBLE|WS_BORDER, 0,0, 300,300, m_hWnd, 0, AfxGetInstanceHandle(), 0 );
|
|
|
|
|
Hi Nave,
Thanks for the reply.
I have created the EditBox using the CreateWindowExW() but still desired character is not getting displayed in place of 'C'.
Is there any special setting or style that we need to specify?
Regards,
Nilesh.
|
|
|
|
|
No I didnt do any thing special.
see my preprocessor definition
WIN32,_DEBUG,_WINDOWS,_AFXDLL,_MBCS
And this is the text that I got when I run the program
ABʄDEFGHI
Isnt this text correct?
|
|
|
|
|
Hi,
Thanks for the reply.
But the text displayed is not correct.
In Lucida san Unicode font instead of square box. it should display the char combinition of
'J' + 'f' + '='. that is unicode value of 0x284. You can refer to Character map in Programs=>Accessories=>system tools=>Character map. select font as Lucida san Unicode. and check character for U+0284 .
I am trying to display that character in my string.It displays the same perfectly if your project setting is _UNICODE.
Is my approach wronge? please let me know.
Regards,
Nilesh.
|
|
|
|
|
Ya.. previously I didnt set the font to "Lucida san Unicode" After i set that too the text came as you said
But I dont understand what wrong with your settings... I started a dialog based application a put the below code in the oninitdialog function
wchar_t str[10];<br />
str[0]=0x41;<br />
str[1]=0x42;<br />
str[2]=0x284;<br />
str[3]=0x44;<br />
str[4]=0x45;<br />
str[5]=0x46;<br />
str[6]=0x47;<br />
str[7]=0x48;<br />
str[8]=0x49;<br />
str[9]=0x00;<br />
CClientDC dc(this);<br />
LOGFONT lf;<br />
memset(&lf, 0, sizeof(lf)); <br />
lf.lfHeight = MulDiv(12, ::GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72);<br />
lf.lfWeight = FW_NORMAL;<br />
lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;<br />
_tcscpy(lf.lfFaceName, _T("Lucida Sans Unicode")); <br />
static CFont m_font;<br />
m_font.CreateFontIndirect(&lf);<br />
HWND hEdit = CreateWindowExW( 0, L"Edit", str, WS_CHILD|WS_VISIBLE|WS_BORDER, 0,0, 300,50, m_hWnd, 0, AfxGetInstanceHandle(), 0 );<br />
::SendMessage( hEdit, WM_SETFONT, (WPARAM)m_font.m_hObject, (LPARAM)TRUE );
|
|
|
|
|
Hi Naveen,
It's working fine in my app too. Thanks a lot.
For setting the font to EditBox I was trying :
SelectObject(::GetDC(hEdit),m_font.m_hObject);
But after using your code. My application was displaying that char.
::SendMessage( hEdit, WM_SETFONT, (WPARAM)m_font.m_hObject, (LPARAM)TRUE );
again thanks a lot. And keep up good work....
Regards,
Nilesh.
|
|
|
|
|
Hi Naveen,
Just a question?
Is it possible to do the same with EditBox created by resource file?
Regards,
Nilesh.
|
|
|
|
|
nilesh.gawade wrote: Is it possible to do the same with EditBox created by resource file?
Sorry that I dont know.
|
|
|
|
|
Hi,
I am able to display the unicode string in EditBox only after creating the EditBox using CreateWindowExW() API.
Now I want to display the same string in EditBox Created using Resource Editor.
May be While creating EditBox through rc file. It might call API in following sequence.
CEdit::Create() => CWnd::Create() => CWnd::CreateWindow() => ::CreateWindow() or ::CreateWindowEx()
Can we modify this flow so that ultimately last call will be ::CreateWindowW() or ::CreateWindowExW()?
Plz Help...
__________________
Regards,
Nilesh Gawade
|
|
|
|
|
nilesh.gawade wrote: CEdit::Create() => CWnd::Create() => CWnd::CreateWindow() => ::CreateWindow() or ::CreateWindowEx()
No this is not correct. The dialog is created using the createdialog() API. inside this api it creats all the controls inside it internally. So the creation of edit control using ::CreateWindow() is done inside the createdialog itself. and it doesnt call the CWnd::Create() at all. After creating all the controls, it subclasses each control if you have made a control variable for it. For this purpose it uses the SubClassWindow() function. So thats how your edit control becomes an object of CEdit.
|
|
|
|
|
nilesh.gawade wrote: Can we modify this flow so that ultimately last call will be ::CreateWindowW() or ::CreateWindowExW()?
Some thing that you can do is create the dialog by your self using the CreateDialogW() function.
|
|
|
|
|
Hi Nave,
Thanks buddy.
I will work on the same.
Regards,
Nilesh.
|
|
|
|
|
For a runtime error to my IVRS application , i found a solution as 'increase the application buffer allocated by the OS' in the internet. I want to know whether there is a way to increase the buffer size of the application?
Thank you
KIRAN PINJARLA
|
|
|
|
|
What buffer are you referring to? Stack space, perhaps?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|