Board index » cppbuilder » how to set a owner of form???
Siney San
![]() CBuilder Developer |
Siney San
![]() CBuilder Developer |
how to set a owner of form???2003-08-02 01:45:18 PM cppbuilder56 hi,all: In a dll, I write a form like below: Tmyfrm* frm=new Tmyfrm(hwnd or TForm*) frm->ShowModal() or frm->Show(); hwnd and TForm* are passed argument into dll. this frm can be displaied, but there is a task button in windows taskbar. I don't want to display it, how should I do to hide it from taskbar. please help me? Thanks. -- Regards for you. Siney |
JD
![]() CBuilder Developer |
2003-08-02 02:42:02 PM
Re:how to set a owner of form???
"Siney San" < XXXX@XXXXX.COM >wrote:
Quote[...] how should I do to hide it from taskbar. you want to be the owner: Tmyfrm *frm = new Tmyfrm( the handle of the owner to be ); If you use: Tmyfrm *frm = new Tmyfrm( this ); the form which allocates it will be the owner. This should clear up the problem. ~ JD |
Siney San
![]() CBuilder Developer |
2003-08-02 05:53:10 PM
Re:how to set a owner of form???
"JD" < XXXX@XXXXX.COM >дÈëÓʼþ news:3f2b5d3a$ XXXX@XXXXX.COM ...
Quote
extern "C" __declspec(dllexport) int MyForm(HWND hwnd,TForm* frm) { Tmyfrm* frm=new Tmyfrm(frm); //new Tmyfrm(hwnd); frm->ShowModal(); } the frm form can be shown and embeded into the parent(owner), if i write code like below: Tmyfrm* frm=new Tmyfrm(NULL); frm->ShowModal(); the frm form can be shown separetely, but there is taskbutton in the taskbar, how should i do to hide this taskbutton in my way. {smallsort} |
JD
![]() CBuilder Developer |
2003-08-02 07:14:35 PM
Re:how to set a owner of form???
"Siney San" < XXXX@XXXXX.COM >wrote:
QuoteI pass this point to my export function and create my form frm. In this case, I'm uncertain of how the compiler will treat the parameter. Third, you are assigning the Owner as it's self. Truth be told, I have never had a need to put a form in a dll but I would think that it should look something like this: extern "C" __declspec(dllexport) int MyForm( HWND hwnd ) { Tmyfrm *A_New_My_Form = new Tmyfrm( hwnd ); return reinterpret_cast<int>( A_New_My_Form ); } and it would be used like this: Tmyform *frm = NULL; frm = (Tmyform*)MyForm( this ); if( frm ) frm->ShowModal(); delete frm; Note that you may need to cast the return differently but I don't think so. Also, if you use frm->Show(), you can't put the delete in there and I'm uncertain what will happen in that case. Although the new form will be destroyed when the Owner of the form is destroyed, I don't know what will happen to memory if the new form is created over and over because it's not deleted. Quotethe frm form can be shown and embeded into the parent(owner), windows messaging while the Owner is responsible for freeing it's resources apon destruction. QuoteTmyfrm* frm=new Tmyfrm(NULL); Quotetaskbar, how should i do to hide this taskbutton in my way. ~ JD |
JD
![]() CBuilder Developer |
2003-08-03 05:16:55 AM
Re:how to set a owner of form???
"Siney San" < XXXX@XXXXX.COM >wrote:
QuoteCould you tell me how to hide taskbutton in all case. |
David Erbas-White
![]() CBuilder Developer |
2003-08-03 06:50:11 AM
Re:how to set a owner of form???
Out of curiousity, what happens if you have MainForm as the Owner of
Form1, and then Form1 creates another child form (Form2) and uses itself as the owner? In such an instance, is a taskbutton created, or not? If so, then doesn't this make it a bit difficult if you have a hierarchichal tree of forms? In the above example, if I close Form1, then Form2 will close, but if both are set to MainForm as the Owner of each, then closing Form1 will not close Form2. Comments appreciated. David Erbas-White JD wrote: Quote"Siney San" < XXXX@XXXXX.COM >wrote: |
JD
![]() CBuilder Developer |
2003-08-03 07:32:20 AM
Re:how to set a owner of form???
David Erbas-White < XXXX@XXXXX.COM >wrote:
Quote[...] if you have MainForm as the Owner of Form1, and then Quote[...] if I close Form1, then Form2 will close, but if both closing a form MAY lead to code that destroys it, the simple act of closing it does not destroy it. ~ JD |
David Erbas-White
![]() CBuilder Developer |
2003-08-03 10:02:52 AM
Re:how to set a owner of form???
JD wrote:
QuoteDavid Erbas-White < XXXX@XXXXX.COM >wrote: set the global form pointer to NULL in the Destroy event (I know, I know, don't use Destroy, use the destructor, but this has been working for me for eons, and I'm of the "if it ain't broke don't fix it" school). Therefore, when I close a form, I am deleting it and freeing the memory. Thus if MainForm creates Form1, and Form1 creates Form2, closing Form1 also closes (and frees) Form2. David Erbas-White |
JD
![]() CBuilder Developer |
2003-08-03 11:18:57 AM
Re:how to set a owner of form???
David Erbas-White < XXXX@XXXXX.COM >wrote:
Quote[...] Therefore, when I close a form, I am deleting it and ~ JD |
JD
![]() CBuilder Developer |
2003-08-03 01:52:17 PM
Re:how to set a owner of form???
David Erbas-White < XXXX@XXXXX.COM >wrote:
Quote[...] It was stated that the only time that a taskbutton want to fix. He just wanted a 'one word' answer on how to not show the new form on the taskbar using his existing code. To that I replied to use the Main form as the Owner. Now, that said, I googled a bit and it's the Parent - not the Owner that effects how it appears on the taskbar. So ... 20 lashes with a wet noodle for me. ~ JD |
Siney San
![]() CBuilder Developer |
2003-08-03 03:35:09 PM
Re:how to set a owner of form???
"JD" < XXXX@XXXXX.COM >дÈëÓʼþ news:3f2c2a47$ XXXX@XXXXX.COM ...
Quote
in Exe { ... ShowMyForm(this,Handle); //this is my main form. } in Dll ShowMyForm(TForm* parent,HWND hwnd) { Tmyfrm* frm=new Tmyfrm(parent); // or Tmyfrm* frm=new Tmyfrm(hwnd); frm->ShowModal(); delete frm; } then, there is a taskbutton in the taskbar. Anyone can tell me why? |
Hans Galema
![]() CBuilder Developer |
2003-08-03 03:48:01 PM
Re:how to set a owner of form???
David Erbas-White wrote:
QuoteIn other words, I don't QuoteNow, I can't really see the above scenario as being all that unusual. |
JD
![]() CBuilder Developer |
2003-08-03 05:00:17 PM
Re:how to set a owner of form???
Hans Galema < XXXX@XXXXX.COM >wrote:
Quote[...] For the whole application there is onlt one taskbutton. { TForm::CreateParams( Params ); Params.ExStyle |= WS_EX_APPWINDOW; Params.WndParent = GetDesktopWindow(); } ~ JD |
Hans Galema
![]() CBuilder Developer |
2003-08-03 10:56:00 PM
Re:how to set a owner of form???
Siney San wrote:
QuoteAll form in one application£¬it must be available.But my form in the DLL, I Kent Reisdorph Using a VCL form in a DLL www.bridgespublishing.com/articles/issues/9809/Using_a_VCL_form_in_a_DLL.htm or tinyurl.com/iwbw was a good start, and it was even easier as described there as the myforms.lib was created by bcp3 compiling myforms.cpp. Can only confirm what you say: there is an extra button in the taskbar with a form from a dll. Don't know the reason. Then I did a google search in *cppbuilder* nesgroups for DLL second taskbar and found the problem reported many times. A cause of this behaviour is described in www.google.nl/groups&lr=&ie=UTF-8&oe=UTF-8&selm=37743655.45251718%40forums.inprise.com&rnum=4 or tinyurl.com/iwcn Hans. |
Siney San
![]() CBuilder Developer |
2003-08-04 01:23:45 PM
Re:how to set a owner of form???QuoteKent Reisdorph dynamic LoadLibrary to call form. QuoteCan only confirm what you say: there is an extra button in the QuoteDon't know the reason. |