in the name of allah
hi everyone
i makes an array "CWnd" class and i want to do "CreateEx" for everyone, but just the first "CreateEx" works and for second and next will error and doesn't work.
i also want set different "Parent" for each (from hwnd).
like : Parent of 1st CWnd is "Cmd" and 2nd is "Calculator" and ... .
can you help me?
what's wrong?
the code i use in create function is like below:
void Theme::CreateTheme(CRect rect,CString Text, CWnd *parent,unsigned short int W,unsigned short int H){
CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_OWNDC, NULL, (HBRUSH)GetStockObject(BLACK_BRUSH), NULL);
CreateEx(0, _T(className),Text, WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0);
Parent = parent;
cdc=Parent->GetWindowDC();
w=W;
h=H;
}
at finally i want to :
Theme t[5];
t[0].CreateTheme(...);
t[1].CreateTheme(...);
t[2].CreateTheme(...);
...
Actually all the Events like "OnPaint" "OnLButtonDown" and ... work except the"OnTimer".
I need to work with "OnTimer" but just this event doesn't work.
can you tell me where the my wrong is?
thanks an advance
______________________________
i declared and use them like below :
____________________________________________________________
Theme theme1;
theme1.CreateTheme(CRect(-2,-2,-1,-1),_T("Hello"),CWnd::FromHandle(hwndDlg),800,500);
Theme theme2;
theme2.CreateTheme(CRect(-2,-2,-1,-1),_T("Hello"),CWnd::FromHandle(hwndDlg),500,300);
____________________________________________________________
in the object "theme1", all of the events work but in the Object "theme2" the "OnTimer()" event doesn't work , of course others event like "OnLButtonDown" and ... work correctly in "theme2".
and this is the contains of .h :
__________________________________________________________________
class Theme : public CWnd{
private:
protected:
virtual void DoDataExchange(CDataExchange* pDX);
public:
CWnd *Parent;
CPoint cursor;
bool drag;
CString path,imagepath;
char DialogMove; char code,sb; short int iimage,bstart,bend, ib; short int w, h,D;
float ani_p, ani_max;
bool ani,mousec;
CRect WRect,rdesktop;
CDC *cdc;
short int lani;
HWND hwndani;
Object *Image;
CRect *Rect;
bool *BEnable; unsigned char ButtonCount,ImageCount,SysButtonCount;
bool Created;
void GotoPage(unsigned char PageNo,unsigned char BStart,unsigned char BEnd);
void OnLButtonDown();
void OnLButtonUp();
void ClearRect(short i,short j,COLORREF color);
bool IsIn(CPoint point,CRect rect);
bool IsInRect(CPoint point,CRect rect,CRect Rectangle);
void Center2Top();
void Top2Center();
void Down2Center();
void Center2Down();
bool AddImage(unsigned char Index,CString ImagePath,unsigned short int X,short int Y);
void AddButton(unsigned char Index,CRect rectangle,bool enable);
void DrawImages(unsigned char alpha,int IImage);
Theme(unsigned char imagecount,unsigned char buttoncount,unsigned char sysbuttoncount);
~Theme(void);
void CreateTheme(CRect rect,CString Text, CWnd *parent,unsigned short int W,unsigned short int H,UINT nID);
afx_msg void OnPaint();
afx_msg void OnTimer(UINT nIDEvent);
DECLARE_MESSAGE_MAP()
};
_________________________
and it's source file is :
-------------------------------------
Theme::Theme(unsigned char imagecount,unsigned char buttoncount,unsigned char sysbuttoncount)
{
TCHAR tc[260];
GetCurrentDirectory(260,tc);
path=tc;
imagepath=path+_T("\\Data\\x85P\\");
drag=lani=mousec=iimage=0;
bstart=bend=-1;
code=ib=-1;sb=1;
Created=0;
ButtonCount=buttoncount;
ImageCount=imagecount;
SysButtonCount=sysbuttoncount;
Image=new Object[ImageCount];
Rect=new CRect[ButtonCount];
BEnable=new bool[ButtonCount];
memset(BEnable,0,ButtonCount);
}
void Theme::CreateTheme(CRect rect,CString Text, CWnd *parent,unsigned short int W,unsigned short int H,UINT nID){
if(!Created){
CString className = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_OWNDC, 0,0,0);
CreateEx(WS_EX_CLIENTEDGE,className,_T("hi"),WS_VISIBLE | WS_CHILD,rect,parent,0,0);
Created=1;
}
Parent = parent;
cdc=Parent->GetWindowDC();
w=W;
h=H;
CWnd::GetDesktopWindow()->GetWindowRect(&rdesktop);
OnPaint();
SetTimer(3,10,0);
}