BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

XP Style close button on Form

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
George P Boutwell
Guest





PostPosted: Thu Apr 20, 2006 2:03 pm    Post subject: XP Style close button on Form Reply with quote



Hello,

I'm trying to manually paint an XP style close button on a portion of a BCB6 form (other than the caption, as this form is an captionless form). Anyone have any experience doing this. As near as I can tell I need to somehow get the uxtheme.h, uxtheme.lib, and link to them and make calls in them, but I'm know sure how to go about getting borland-friendly versions of these. Any help please?

Thanks,

George
Back to top
Michael Gillen
Guest





PostPosted: Thu Apr 20, 2006 3:03 pm    Post subject: Re: XP Style close button on Form Reply with quote



George P Boutwell wrote:

Quote:

Hello,

I'm trying to manually paint an XP style close button on a portion of a BCB6 form (other than
the caption, as this form is an captionless form). Anyone have any experience doing this. As
near as I can tell I need to somehow get the uxtheme.h, uxtheme.lib, and link to them and make
calls in them, but I'm know sure how to go about getting borland-friendly versions of these. Any
help please?

For BCB6 I use Theme Manager.
http://www.soft-gems.net/ThemeManager.php

--
-Michael Gillen
Back to top
JD
Guest





PostPosted: Thu Apr 20, 2006 10:03 pm    Post subject: Re: XP Style close button on Form Reply with quote



"George P Boutwell" <lewtuobg.reverse-for-email (AT) valleyhope (DOT) com> wrote:
Quote:


Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard retuen at the
end of each line. If you're using a reader, look for an option
to set it's line width.

Quote:
I'm trying to manually paint an XP style close button

//-------------------------------------------------------------
#ifndef Unit2H
#define Unit2H
//-------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//-------------------------------------------------------------
#include <tmschema.h>
//-------------------------------------------------------------
typedef HANDLE HTHEME;
typedef BOOL WINAPI (*DLLISTHEMEACTIVE)();
typedef HTHEME WINAPI (*DLLOPENTHEMEDATA)( HWND, LPCWSTR );
typedef HRESULT WINAPI (*DLLDRAWTHEMEBACKGROUND)( HTHEME, HDC, int, int, const RECT*, OPTIONAL const RECT* );
typedef HRESULT WINAPI (*DLLCLOSETHEMEDATA)( HTHEME );
//-------------------------------------------------------------
class TForm2 : public TForm
{
private:
bool FCanTheme;
HINSTANCE hUxTheme;
DLLISTHEMEACTIVE IsThemeActive;
DLLOPENTHEMEDATA OpenThemeData;
DLLDRAWTHEMEBACKGROUND DrawThemeBackground;
DLLCLOSETHEMEDATA CloseThemeData;
bool __fastcall InitializeTheming();
public:
__fastcall TForm2(TComponent* Owner);
__fastcall ~TForm2();
};
//-------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//-------------------------------------------------------------
#endif



//-------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
//-------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TForm2 *Form2;
//-------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner) : TForm(Owner)
{
hUxTheme = NULL;
IsThemeActive = NULL;
OpenThemeData = NULL;
DrawThemeBackground = NULL;
CloseThemeData = NULL;
FCanTheme = InitializeTheming();
}
//-------------------------------------------------------------
__fastcall TForm2::~TForm2()
{
if( hUxTheme ) ::FreeLibrary( hUxTheme );
}
//-------------------------------------------------------------
bool __fastcall TForm2::InitializeTheming()
{
bool Result = false;
if( !hUxTheme )
{
hUxTheme = ::LoadLibrary( "UxTheme.dll" );
if( hUxTheme )
{
IsThemeActive = reinterpret_cast<DLLISTHEMEACTIVE>( ::GetProcAddress(hUxTheme, "IsThemeActive") );
if( IsThemeActive )
{
if( IsThemeActive() )
{
OpenThemeData = reinterpret_cast<DLLOPENTHEMEDATA> ( ::GetProcAddress(hUxTheme, "OpenThemeData" ));
DrawThemeBackground = reinterpret_cast<DLLDRAWTHEMEBACKGROUND> ( ::GetProcAddress(hUxTheme, "DrawThemeBackground" ));
CloseThemeData = reinterpret_cast<DLLCLOSETHEMEDATA> ( ::GetProcAddress(hUxTheme, "CloseThemeData" ));
if( OpenThemeData && DrawThemeBackground && CloseThemeData ) Result = true;
}
}
}
}
return Result;
}
//-------------------------------------------------------------


An example of drawing a ThemePart (small themed close button):

if( FCanTheme )
{
HTHEME hTheme = OpenThemeData( Handle, L"WINDOW" );
if( hTheme )
{
TRect R = Rect( 0, 0, ::GetSystemMetrics(SM_CXMENUSIZE), ::GetSystemMetrics(SM_CYMENUSIZE) );
// use win32 API OffsetRect to position the TRect accordlingly
DrawThemeBackground( hTheme, Canvas->Handle, WP_CLOSEBUTTON, CBS_NORMAL, &R, NULL );
CloseThemeData( hTheme );
}
else
{
// draw it un-themed
}
}
else
{
// draw it un-themed
}

If you want a normal close button, use SM_CXSIZE and SM_CYSIZE
with the calls to GetSystemMetrics when sizing the TRect. If
you want to clip the extra pixels that surround the button,
the last parameter in the call to DrawThemeBackground is a
clipping rect.

Here's a list of parts and their states for the WINDOW class.
Where no states are listed, use a one (1) for the state.:

WP_CAPTION CS_ACTIVE, CS_DISABLED, CS_INACTIVE
WP_CAPTIONSIZINGTEMPLATE
WP_CLOSEBUTTON CBS_DISABLED, CBS_HOT, CBS_NORMAL, CBS_PUSHED
WP_DIALOG
WP_FRAMEBOTTOM FS_ACTIVE, FS_INACTIVE
WP_FRAMEBOTTOMSIZINGTEMPLATE
WP_FRAMELEFT FS_ACTIVE, FS_INACTIVE
WP_FRAMELEFTSIZINGTEMPLATE
WP_FRAMERIGHT FS_ACTIVE, FS_INACTIVE
WP_FRAMERIGHTSIZINGTEMPLATE
WP_HELPBUTTON HBS_DISABLED, HBS_HOT, HBS_NORMAL, HBS_PUSHED
WP_HORZSCROLL HSS_DISABLED, HSS_HOT, HSS_NORMAL, HSS_PUSHED
WP_HORZTHUMB HTS_DISABLED, HTS_HOT, HTS_NORMAL, HTS_PUSHED
WP_MAX_BUTTON MAXBS_DISABLED, MAXBS_HOT, MAXBS_NORMAL, MAXBS_PUSHED
WP_MAXCAPTION MXCS_ACTIVE, MXCS_DISABLED, MXCS_INACTIVE
WP_MDICLOSEBUTTON CBS_DISABLED, CBS_HOT, CBS_NORMAL, CBS_PUSHED
WP_MDIHELPBUTTON HBS_DISABLED, HBS_HOT, HBS_NORMAL, HBS_PUSHED
WP_MDIMINBUTTON MINBS_DISABLED, MINBS_HOT, MINBS_NORMAL, MINBS_PUSHED
WP_MDIRESTOREBUTTON RBS_DISABLED, RBS_HOT, RBS_NORMAL, RBS_PUSHED
WP_MDISYSBUTTON SBS_DISABLED, SBS_HOT, SBS_NORMAL, SBS_PUSHED
WP_MINBUTTON MINBS_DISABLED, MINBS_HOT, MINBS_NORMAL, MINBS_PUSHED
WP_MINCAPTION MNCS_ACTIVE, MNCS_DISABLED, MNCS_INACTIVE
WP_RESTOREBUTTON RBS_DISABLED, RBS_HOT, RBS_NORMAL, RBS_PUSHED
WP_SMALLCAPTION CS_ACTIVE, CS_DISABLED, CS_INACTIVE
WP_SMALLCAPTIONSIZINGTEMPLATE
WP_SMALLCLOSEBUTTON CBS_DISABLED, CBS_HOT, CBS_NORMAL, CBS_PUSHED
WP_SMALLFRAMEBOTTOM FS_ACTIVE, FS_INACTIVE
WP_SMALLFRAMEBOTTOMSIZINGTEMPLATE
WP_SMALLFRAMELEFT FS_ACTIVE, FS_INACTIVE
WP_SMALLFRAMELEFTSIZINGTEMPLATE
WP_SMALLFRAMERIGHT FS_ACTIVE, FS_INACTIVE
WP_SMALLFRAMERIGHTSIZINGTEMPLATE
WP_SMALLHELPBUTTON HBS_DISABLED, HBS_HOT, HBS_NORMAL, HBS_PUSHED
WP_SMALLMAXBUTTON MAXBS_DISABLED, MAXBS_HOT, MAXBS_NORMAL, MAXBS_PUSHED
WP_SMALLMAXCAPTION MXCS_ACTIVE, MXCS_DISABLED, MXCS_INACTIVE
WP_SMALLMINCAPTION MNCS_ACTIVE, MNCS_DISABLED, MNCS_INACTIVE
WP_SMALLRESTOREBUTTON RBS_DISABLED, RBS_HOT, RBS_NORMAL, RBS_PUSHED
WP_SMALLSYSBUTTON SBS_DISABLED, SBS_HOT, SBS_NORMAL, SBS_PUSHED
WP_SYSBUTTON SBS_DISABLED, SBS_HOT, SBS_NORMAL, SBS_PUSHED
WP_VERTSCROLL VSS_DISABLED, VSS_HOT, VSS_NORMAL, VSS_PUSHED
WP_VERTTHUMB VTS_DISABLED, VTS_HOT, VTS_NORMAL, VTS_PUSHED

For a complete list of theme Classes, their parts and their
states, examine tmschema.h.

For a complete list of theming functions, examine uxtheme.h.

~ JD
Back to top
Regis St-Gelais
Guest





PostPosted: Fri Apr 21, 2006 2:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"JD" <nospam (AT) nospam (DOT) com> a écrit dans le message de news:
4447fece$1 (AT) newsgroups (DOT) borland.com...
Quote:

Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard retuen at the
end of each line. If you're using a reader, look for an option
to set it's line width.


I read his post with Outlook Express and I have no wrap problems.
I think that your reader should wrap the lines himself.

--
Regis St-Gelais
www.laubrass.com
Back to top
Mark Jacobs
Guest





PostPosted: Fri Apr 21, 2006 3:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Regis St-Gelais" <regis.st-gelais (AT) NOSPAMlaubrass (DOT) com> wrote in message
news:4448de53$1 (AT) newsgroups (DOT) borland.com...
Quote:
"JD" <nospam (AT) nospam (DOT) com> a écrit dans le message de news:
4447fece$1 (AT) newsgroups (DOT) borland.com...

Please wrap your lines when you post. Your editor may visually
wrap them for you but you need to enter a hard retuen at the
end of each line. If you're using a reader, look for an option
to set it's line width.


I read his post with Outlook Express and I have no wrap problems.
I think that your reader should wrap the lines himself.

I also get no wrapping problems with his post under OE.
--

Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
Back to top
JD
Guest





PostPosted: Fri Apr 21, 2006 4:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Regis St-Gelais" <regis.st-gelais (AT) NOSPAMlaubrass (DOT) com> wrote:
Quote:

[...] If you're using a reader, [...]

I read his post with Outlook Express and I have no wrap
problems. I think that your reader should wrap the lines
himself.

I, like many others, do not use a reader and prefere the web
interface. Have a look at what it looks like if the lines are
not wrapped:

http://newsgroups.borland.com/cgi-bin/dnewsweb?cmd=article&group=borland.public.cppbuilder.nativeapi&item=18520&utag=

If you then click on Post Response (you can cancel later just
by closing the window), you'll notice that you are asked to
press enter at the end of each line. The server wants cr/lf
pairs and it's a one-time fix to set the line width of your
reader.

~ JD
Back to top
JD
Guest





PostPosted: Fri Apr 21, 2006 4:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> wrote:
Quote:

I also get no wrapping problems with his post under OE.

It's not about how your reader reads it. It's about how his
reader writes it. See my other reply.

~ JD
Back to top
Bob Gonder
Guest





PostPosted: Fri Apr 21, 2006 4:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

Regis St-Gelais wrote:

Quote:
I read his post with Outlook Express and I have no wrap problems.
I think that your reader should wrap the lines himself.

If I wanted to use MS's crappy software, I wouldn't be in a Borland
newsgroup.
Back to top
Regis St-Gelais
Guest





PostPosted: Mon Apr 24, 2006 1:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"JD" <nospam (AT) nospam (DOT) com> a écrit dans le message de news:
4448f7e2$1 (AT) newsgroups (DOT) borland.com...
Quote:

I, like many others, do not use a reader and prefere the web
interface. Have a look at what it looks like if the lines are
not wrapped:


http://newsgroups.borland.com/cgi-bin/dnewsweb?cmd=article&group=borland.public.cppbuilder.nativeapi&item=18520&utag=


Then I think that the web interface should wrap it automaticaly.


Quote:
If you then click on Post Response (you can cancel later just
by closing the window), you'll notice that you are asked to
press enter at the end of each line. The server wants cr/lf
pairs and it's a one-time fix to set the line width of your
reader.

When I hit Post Response I can see a line wrapped version and the browser
does not ask me to press enter.


--
Regis St-Gelais
www.laubrass.com
Back to top
Alan Bellingham
Guest





PostPosted: Mon Apr 24, 2006 2:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Regis St-Gelais" <regis.st-gelais (AT) NOSPAMlaubrass (DOT) com> wrote:

Quote:
Then I think that the web interface should wrap it automaticaly.

You may think so. But that is changing the spec, and many would be
rather unhappy about a unilateral spec change.

Ideally, all mail and news clients should always have used automatic
wrapping, including getting quoting right. But when email/news was
invented, most clients had fixed fonts and fixed size windows, so
wrapping wasn't considered. Instead, all halfway-decent mail/news
clients have the ability to set line lengths.

Or in other words, the historic design decision has been to place the
burden of line breaking on the sender, not the receiver.

Alan Bellingham
--
ACCU Conference 2007 - venue to be determined.
Back to top
Boba
Guest





PostPosted: Mon Apr 24, 2006 3:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid> wrote in message
news:vuth42lp643pg8s0kp9eifuhjom88dq455 (AT) 4ax (DOT) com...

Quote:
If I wanted to use MS's crappy software, I wouldn't be in a Borland
newsgroup.

If Borland's good software worked the way it's suppose to,
There wouldn't be a need for this newsgroup...

\|/
o^o
-

Boba
Back to top
JD
Guest





PostPosted: Mon Apr 24, 2006 4:03 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Regis St-Gelais" <regis.st-gelais (AT) NOSPAMlaubrass (DOT) com> wrote:
Quote:

[...] the browser does not ask me to press enter.

Look again.

~ JD
Back to top
Tom Woodrow
Guest





PostPosted: Sun May 14, 2006 9:14 pm    Post subject: Re: XP Style close button on Form Reply with quote

Nonsense,

Even if BCB were perfect, and I know it is not, there is still a need
for these groups. Often I have just needed a little nudge in the right
direction to get portions of my code to work, nothing to do with BCB
bugs or documentation, just things that are not obvious to me.

Tom Woodrow


Boba wrote:
Quote:
"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid> wrote in message
news:vuth42lp643pg8s0kp9eifuhjom88dq455 (AT) 4ax (DOT) com...


If I wanted to use MS's crappy software, I wouldn't be in a Borland
newsgroup.


If Borland's good software worked the way it's suppose to,
There wouldn't be a need for this newsgroup...

\|/
o^o
-

Boba

Back to top
gizmo
Guest





PostPosted: Sun May 14, 2006 9:14 pm    Post subject: Re: XP Style close button on Form Reply with quote

"JD" <nospam (AT) nospam (DOT) com> wrote:

Quote:

For a complete list of theme Classes, their parts and their
states, examine tmschema.h.

For a complete list of theming functions, examine uxtheme.h.

~ JD


How I can draw XP-Toolbar? You has a small example of this drawing?

Thank you.
Back to top
Boba
Guest





PostPosted: Tue May 16, 2006 2:14 pm    Post subject: Re: XP Style close button on Form Reply with quote

"Tom Woodrow" <tomwoodrow (AT) comcast (DOT) net> wrote in message
news:4467782c$1 (AT) newsgroups (DOT) borland.com...
Quote:
...
... there is still a need for these groups.

Most of this NG topics have nothing to do with Borland:
it is just pure MS issues (that's why I like this one too).
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.