|
Windows sends WM_NC(something) that stands for No Client.
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
How can I get a rotated standard region(such as: ellise region, roundrect region)?
HRGN hRgn = CreateRectRgn(0,0,220,120);
DWORD size = GetRegionData( hRgn, 1, NULL);
RGNDATA *pData = (RGNDATA*)GlobalAlloc(GMEM_FIXED|GMEM_MOVEABLE,size);
GetRegionData(hRgn, size,pData);
double a = 0.5; // 0
xform.eM11 = (float)cos(a);
xform.eM12 = (float)sin(a);
xform.eM21 = -xform.eM12;
xform.eM22 = xform.eM11;
xform.eDx = 0;
xform.eDy = 0;
HRGN hNewRgn = ExtCreateRegion(&xform,pData->rdh.nRgnSize,pData);
// failure! why ?
GlobalFree(pData);
DeleteObject(hRgn);
DeleteObject(hNewRgn);
Thank you very much!
|
|
|
|
|
Try with
HRGN hNewRgn = ExtCreateRegion(&xform,size,pData);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanl: Joaquín M López Muñoz, now, I can get the rotated region!
the modify codes:
DWORD size = GetRegionData(hRgn, sizeof(RGNDATA), NULL);
RGNDATA *pData = (RGNDATA*)GlobalAlloc(GMEM_FIXED|GMEM_MOVEABLE,size);
GetRegionData(hRgn, size,pData);
a = 0.5; // 0
xform.eM11 = (float)cos(a);
xform.eM12 = (float)sin(a);
xform.eM21 = -xform.eM12;
xform.eM22 = xform.eM11;
xform.eDx = 0;
xform.eDy = 0;
HRGN hNewRgn = ExtCreateRegion(&xform,size,pData);
GlobalFree(pData);
DeleteObject(hRgn);
CodeProject.com Forum problems or suggestions?
Reply to a Message
Here you can reply to a message in the current discussion thread
Forum Visual C++
Subject: Re: How can I get a rotated region?
Sender: Joaquín M López Muñoz
Date: 2:45 31 Jan '02
|
|
|
|
|
how do i get a button to check if text has been entered into an edit box?
|
|
|
|
|
QnD way:
In the "on click" message handler for the button, call UpdateData(TRUE) to save the contents of the edit box into it's associated member variable (I assume you're using DDX). Then check the length of that string to see if the user entered anything.
Jon Sagara
What about ?
|
|
|
|
|
Use Class Wizzard to add a message map function to the EDIT Control, that will invoke its handler when it being edited. EN_UPDATE is the message you must add a handler for. Thus, this function will invoke everytime the contents of the edit control is changed.
"Needless redundancy is the hobgoblin of software engineering." - Peter Darnell
|
|
|
|
|
Hi everyone. I have a control bar with a combo box on it, in which I want to put in all of the names of the fonts installed on the system (just like Word does, for example).
Is there an MFC or API method of getting a list of the fonts installed on the system? I serached through MSDN without much luck, maybe I am using the wrong words to search on? I only need to get the names of the fonts (like they appear in Word).
|
|
|
|
|
How about EnumFontFamiliesEx(...) ?
Jon Sagara
What about ?
|
|
|
|
|
void SNDLL_API SetFontSizeToCombo( HDC hDC,LPCTSTR lpszFamily,CComboBox & Box )
{
Box.ResetContent();
TEnumSizeDataStru Data;
Data.pComboBox = &Box; Data.yPerInch = GetDeviceCaps(hDC,LOGPIXELSY);
EnumFontFamilies(hDC, lpszFamily, (FONTENUMPROC)ProcEnumSizeToCombo, (LPARAM)&Data);
}
int APIENTRY ProcEnumSizeToCombo(
LPLOGFONT lpLogFont,
NEWTEXTMETRIC * lpTEXTMETRICs,
DWORD fFontType,
LPVOID lpData)
{
CComboBox * pComboBox = (((TEnumSizeDataStru *)lpData)->pComboBox);
LONG yPerInch = ((TEnumSizeDataStru *)lpData)->yPerInch;
CString strSize; strSize.Format("%2d",lpTEXTMETRICs->ntmSizeEM);
if( pComboBox->FindString(-1,strSize)==CB_ERR )
pComboBox->AddString(strSize);
return 1;
}
|
|
|
|
|
|
Hi, can anyone tell me how an ActiveX control can terminate its container application? I have seen this done but cannot work out how.
Also how can a control get the file location of the container application?
Any help at all would be appreciated.
Thanks, Worzle
|
|
|
|
|
Assuming the control is a child to the application (this is not always true).
Look up AfxGetMainWnd in the help.
//The following line send a WM_CLOSE message
// to the Application's main window. This will cause the
// Application to exit.
AfxGetMainWnd()->PostMessage(WM_CLOSE, 0, 0);
|
|
|
|
|
Thats great, thanks a lot!
|
|
|
|
|
can some one please tell me how to read some input like this:
" john Smith 444-44-4444
jamie Scott 333-33-3333"
and then i have to create objects of these things.
thank you
|
|
|
|
|
See to:
MFC samples by VC6
|
|
|
|
|
My application needs that i use a ComboBox and ListBox.The ComboBox will display a drive or directory in the system and my listbox will display all the subdirectories.This comboBox and listbox get displayed in a Dialog application. There is a function called CWnd::DlgDirListComboBox .As per documentation this is supposed to load a directory.
there are 2 classes in my application
CForDialog and CForApp .
I used this line of code inside InitDialog in CForDialog class .......throws unhandled exception
this->DlgDirListComboBox(_T(""),IDC_COMBO1,IDC_LIST1,DDL_DIRECTORY|DDL_EXCLUSIVE);
can u help
|
|
|
|
|
You must not give a constant string as path spec :
"
lpPathSpec
Points to a null-terminated string that contains the path or filename. DlgDirListComboBox modifies this string, which should be long enough to contain the modifications. For more information, see the following “Remarks” section.
"
HTH, Jens
|
|
|
|
|
The Directory Path must not be a static path in DlgDirList-Method!
Sample:
IDC_LIST1 is the box to be filled...
CString *temp1 = new CString("c:\\tmp\\style\\*.xsl");
LPTSTR str1 = temp1->GetBuffer(temp1->GetLength());
int ret=this->DlgDirList(str1,IDC_LIST1,0,0);
|
|
|
|
|
template<class Type> class CBase
template<class Type> class CChild : private CBase<Type>
CChild has members which point to a heap and have related Get and Set functions.
Is it possible for CBase to call it's child's member functions Get and Set to manipulate the heap...?
I've considered passing a pointer to the heap to CBase and just copying the Get/Set functionality into the base class, however this doesn't see to be appropriate and i might as well put everything into one class.
Using RTTI is it possible to obtain pointer to CChild from CBase and call it's Set/Get functions on the current heap rather than using my approach...?
TIA
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
HockeyDude wrote:
I've considered passing a pointer to the heap to CBase and just copying the Get/Set functionality into the base class, however this doesn't see to be appropriate and i might as well put everything into one class.
If CBase needs to operate on that data, why wouldn't you place that data in the CBase class? That is where it seems to belong to me.
HockeyDude wrote:
Using RTTI is it possible to obtain pointer to CChild from CBase and call it's Set/Get functions on the current heap rather than using my approach...?
This can be done, but once again, I believe that the data should probably go into the CBase class itself.
Could you give an example of why you want to put this data in the CChild class, and maybe there is a better solution that I could suggest?
kilowatt
|
|
|
|
|
CBase is actually CUndoBuffer and CChild is CBuffer
CBuffer has Get/Set/Del accessor/mutators
friend QSort
and is only going to get more complicated as time goes on.
CUndoBuffer implements a Push/Pop stack with
CanUndo
DoRedo
DoUndo
Clear
SetSize etc...
It makes easier sense to put em' all into one class, but i think more logical sense to seperate them
Cbuffer works with the heap funcitons and is getting pretty complex
CundoBuffer works with new/delete and is pretty trivial until realizing DoUndo/DoRedo don't have explicit(?) access to the Child's Redo/Undo
I personally would prefer to keep them seperated.
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
You can adopt the following approach:
template <class Type, class TChild> class CBase
{
...
void SomeMethod()
{
static_cast<TChild&>(*this).Get(...);
static_cast<TChild&>(*this).Set(...);
}
}:
template <class Type> class CChild: private CBase<Type, CChild>
{
...
}; See the idea? CChild passes its own type to CBase, thus informing the base class about whom child to delegate Get and Set . It's like a compile-time virtual function mechanism. This approach is extensively exploited in ATL.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Really...this will work..?
Sweet...I hope it does, i won't have to recosider my design
And it should solve all my problems
Really appreciate it!!
Thanx again and again
"An expert is someone who has made all the mistakes in thier field" - Niels Bohr
|
|
|
|
|
Seems like it shouldn't work because of circular references, but the fact is that this little trick compiles fine (and what's more, it does not incur in any run-time penalty, everything is resolved on compilation). To the best of my knowledge, it was the ATL guys the first who used this idiom.
Templates are a constant source of enjoyment and productivity. I feel sorry about C# & Java users with its "single hierarchy"/"no hassles"/"type-unsafe containers" languages!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|