Guru3D.com Forums

Go Back   Guru3D.com Forums > General > Programming/Html
Programming/Html C++,Visual Basic,HTML,Flash,OpenGL,Modelling,Java.


Reply
 
Thread Tools Display Modes
Old
  (#1)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 06-01-2002, 17:10 | posts: 1,463 | Location: UK

<A HREF="http://www.gametutorials.com/download/CodeDump/RegionSkinning_Win32.zip" TARGET=_blank>http://www.gametutorials.com/download/CodeDump/RegionSkinning_Win32.zip</A>
   
Reply With Quote
 
Old
  (#2)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 06-09-2002, 14:16 | posts: 1,619 | Location: C000-CFFF

Detonate, I could <IMG SRC="smileys/kiss.gif"> you if you were a woman....<br>
<br>
THANK YOU!
   
Reply With Quote
Old
  (#3)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 06-09-2002, 14:35 | posts: 1,463 | Location: UK

<BLOCKQUOTE>quote:<HR>Originally posted by Kennung Eins:<br>
<b>Detonate, I could <IMG SRC="smileys/kiss.gif"> you if you were a woman....<br>
THANK YOU!</b><HR></BLOCKQUOTE><br>
you know i'm glad to be a few hundred miles away from you when you say stuff like that <IMG SRC="smileys/biggrin.gif">
   
Reply With Quote
Old
  (#4)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 06-10-2002, 15:35 | posts: 1,619 | Location: C000-CFFF

*G* nah, really cool thing you found there.<br>
I hope I can make anything out of its c++ code... (I use Delphi...)
   
Reply With Quote
 
Old
  (#5)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 06-11-2002, 01:12 | posts: 1,463 | Location: UK

one thing though, i couldn't figure out how to chage to squares, triangles etc, only the ellipse as shown <IMG SRC="smileys/frown.gif">
   
Reply With Quote
Old
  (#6)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 06-15-2002, 13:26 | posts: 1,619 | Location: C000-CFFF

hmmz I hope I can find some time to have a deeper look at it asap...
   
Reply With Quote
Old
  (#7)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 06-30-2002, 21:07 | posts: 1,619 | Location: C000-CFFF

Yeah! I got it working!

But indeed this changes EVERYTHING I ever learned about Delphi programming.
I will not be able to use standart delphi forms and tools anymore...howdy, now you brought me into something completely new.
If you want, you can have a look at it at my site
(it's with sources for both C++ and Delphi)



I definately want to keep this *new* programming style (compared to the normal Delphi style), so all the programming of the future will be a "little bit" delayed.

Last edited by Kennung Eins; 04-26-2010 at 20:32.
   
Reply With Quote
Old
  (#8)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 07-19-2002, 16:45 | posts: 1,463 | Location: UK

Ok, another thing i couldn't figure out was how to go straight into the skinned window mode - without the Press The Spacebar thing. Maybe you managed to figure it out, but i couldn't... i'm too dumb for programming
   
Reply With Quote
Old
  (#9)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 07-19-2002, 17:15 | posts: 1,619 | Location: C000-CFFF

[edit]...oh sorry I didn't read your post correctly[/edit]

Last edited by Kennung Eins; 07-19-2002 at 17:21.
   
Reply With Quote
Old
  (#10)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 07-19-2002, 17:45 | posts: 1,619 | Location: C000-CFFF

Ok, I just had a look at it now, here's the solution:
Code:
function WinMain(hInstance: HINST;hPrevInstance: HINST;lpCmdLine: PChar;nCmdShow: integer): integer; stdcall;
const IDB_SKIN=101;
var
    msg: TMsg;      // Windows Message Structure
    dmScreenSettings: DEVMODE;
    wndclass:TWndClass; // Windows Class Structure Used To Set Up The Type Of Window
    iSw, iSh, iW2, iH2:integer;
    hSkinBmp,hOldBmp:HBITMAP;
    ps: PaintStruct;

begin

     hSkinBmp := LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_SKIN));

     dcSkin := CreateCompatibleDC(0);

     hOldBmp := HBITMAP(SelectObject(dcSkin, hSkinBmp));

     ZeroMemory( @wndclass, sizeof( wndclass ) );

     wndclass.style := CS_HREDRAW or CS_VREDRAW;
     wndclass.lpfnWndProc := @WndProc;
     wndclass.cbClsExtra := 0;
     wndclass.cbWndExtra := 0;
     wndclass.hInstance := GetModuleHandle(NiL);
     wndclass.hIcon := LoadIcon(0, IDI_WINLOGO);
     wndclass.hCursor := LoadCursor(0, IDC_ARROW);
     wndclass.hbrBackground := HBRUSH(GetStockObject(BLACK_BRUSH));
     wndclass.lpszMenuName := nil;
     wndclass.lpszClassName := 'w32skin';

     if(RegisterClass(wndclass)=0) then
     begin
       MessageBox(0,'Failed To Register The Window Class.','Error',MB_OK or MB_ICONERROR);
       Result := 0;
       exit;
     end;

     h_Wnd := CreateWindow('w32skin',
     		            '        w32skin',
     	                      WS_OVERLAPPEDWINDOW,
     	                      300,
     						  200,
                                                  320,
                                                  240,		// The Width And Height Of The WIndow

                              0,
                                                  0,
                                                  hInstance,
                                                  nil);
     if (h_Wnd = 0) then
     begin
       MessageBox(0,'Window Creation Error.','Error',MB_OK or MB_ICONERROR);
       Result := 0;
       exit;
     end;

     ShowWindow(h_Wnd, SW_SHOW);
     UpdateWindow(h_Wnd);
     SetFocus(h_Wnd);

    RegionMe;
    BeginPaint(h_Wnd,ps);

    SkinMe(ps.hdc);
    SetBkMode(ps.hdc,TRANSPARENT);
    EndPaint(h_wnd,ps);
    bRegioned:=false;

     while ( true ) do begin
		// Process All Messages
       while (PeekMessage(msg, 0, 0, 0, PM_NOREMOVE)) do begin
         if (GetMessage(msg, 0, 0, 0)) then begin
           TranslateMessage(msg);
           DispatchMessage(msg);
         end
         else begin
           Result := 1;
           exit;
         end;
       end;
//       SwapBuffers(h_DC);
     end;
     SelectObject(dcSkin, hOldBmp);
     DeleteObject(hSkinBmp);
     DeleteDC(dcSkin);
     DestroyWindow(h_Wnd);
end;
The code's in Object Pascal (delphi) but should be easily to understand for you too.

The only difference is the
Code:
    RegionMe;
    BeginPaint(h_Wnd,ps);

    SkinMe(ps.hdc);
    SetBkMode(ps.hdc,TRANSPARENT);
    EndPaint(h_wnd,ps);
    bRegioned:=false;
in the middle of the code.

Works good

[edit]
Oh and in the WndProc method you should remove this line
Code:
		if (bRegioned) then
From the Mousebutton check:
Code:
             WM_LBUTTONDOWN:
             begin

			SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0);
		exit;
             end;
[/edit]

Last edited by Kennung Eins; 07-19-2002 at 17:51.
   
Reply With Quote
 
Old
  (#11)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 07-19-2002, 21:06 | posts: 1,463 | Location: UK

thx Kennung, i'll try it later
   
Reply With Quote
Old
  (#12)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 08-08-2002, 15:03 | posts: 1,619 | Location: C000-CFFF

Hey Detonate,
ehm perhaps you can help me with that...

You use C++?
C++ has the Resource Editor, Delphi has a similar thing called Image Editor (which can create resource files as well) ... now tell me, does the C++ Res Editor also only support 4-bit BMP files?

I tried the Delphi Res Editor and it says it supports up to 256 colors (8 bit) [which is also not enough for me, but it would be at least well enough], but nooooo.... the program lies, it only supports 16-colors (4bit) BMPs. .. whenever I use a 8-bit bmp it resamples the file to 4 bit.

Now...does the VC++ Res Editor support at least real 8-bit bmps?
   
Reply With Quote
Old
  (#13)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 08-08-2002, 15:44 | posts: 1,463 | Location: UK

It SUPPORTS any type of bitmap, however it will only display in it's own picture editor the ones that have up to 256 colours. They will still work in any apps you decide to create though.
   
Reply With Quote
Old
  (#14)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 08-08-2002, 16:35 | posts: 1,619 | Location: C000-CFFF

oh really?
Damn!

But how do I get the 8+ bit pictures into the resource file when the resource file editor doesn't let me open the file?
   
Reply With Quote
Old
  (#15)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 08-09-2002, 12:18 | posts: 1,463 | Location: UK

It could be different in Delphi then, but in VC6 i know you can do it
   
Reply With Quote
Old
  (#16)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 08-11-2002, 21:40 | posts: 1,619 | Location: C000-CFFF

oki,
I have found another way, I think.

the LoadImage function works really good, as far as I can see now...

It's even a lot better than resource files as the folks could make their own skins really easy that way...

Last edited by Kennung Eins; 04-26-2010 at 20:33.
   
Reply With Quote
Old
  (#17)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 08-11-2002, 21:56 | posts: 1,463 | Location: UK

Now all we need is a prog that can read PNG files as well as the Alpha data that comes with it. Can't think of any simpler ways to make a custom shaped window than that.
   
Reply With Quote
Old
  (#18)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 08-12-2002, 09:29 | posts: 1,619 | Location: C000-CFFF

Detonate, that idea is great.

I already thought of using the LoadImage function with the IMAGE_ICON parameter, so that it will load an icon.
This has the advantage that the pixel in the lower left edge of the pic will be used as transparent color for the whole picture.
This would work, although I didn't try it yet.

Mh...if the shapes would only be circles then we wouldn't have any problem, we could use the MakeCircularRegion function (or whatever this function was called)...

[edit]
ehm, I just tried this:
Code:
    hbitmap := HBITMAP(LoadImage(hinstance,'MyBitmap.bmp',IMAGE_BITMAP,0,0,LR_LOADFROMFILE or LR_LOADTRANSPARENT));
the loadtransparent is responsible for the effect I explained above, you don't need Icons for that (didn't know that yet).

It makes the lower left edge-pixel transparent, as well as all other pixels with the same RGB values.

[edit2]
mh but this only works with 8-bit BMPs... grrr...

Last edited by Kennung Eins; 08-12-2002 at 10:13.
   
Reply With Quote
Old
  (#19)
Kennung Eins
Maha Guru
 
Kennung Eins's Avatar
 
Videocard: 9600GT
Processor: Pentium-M 2.27Ghz
Mainboard: AOpen i915GMm-HFS
Memory: 2x1GB GeiL DDR2
Soundcard: integrated RTL HDA
PSU: AcBel Api4Pc01
Default 08-12-2002, 12:13 | posts: 1,619 | Location: C000-CFFF

Quote:
Originally posted by Detonate
one thing though, i couldn't figure out how to chage to squares, triangles etc, only the ellipse as shown <IMG SRC="smileys/frown.gif">
Oh I just figured out that we don't need any transparency settings or similar things.

Just use this procedure:
Code:
procedure RegionMe(hWnd:HWND);
var hRegion1:HRGN;
    points:array[0..9] of TPOINT;
begin
    Points[0].X := 3;
    Points[0].Y := 93;
    Points[1].X := 79;
    Points[1].Y := 57;
    Points[2].X := 128;
    Points[2].Y := 39;
    Points[3].X := 217;
    Points[3].Y := 16;
    Points[4].X := 293;
    Points[4].Y := 4;
    Points[5].X := 388;
    Points[5].Y := 4;
    Points[6].X := 463;
    Points[6].Y := 16;
    Points[7].X := 552;
    Points[7].Y := 36;
    Points[8].X := 610;
    Points[8].Y := 59;
    Points[9].X := 680;
    Points[9].Y := 93;

  hRegion1:=CreatePolygonRgn(points[0], length(points), ALTERNATE);
  OffsetRgn(hRegion1, GetSystemMetrics(SM_CXBORDER)*4, GetSystemMetrics(SM_CYCAPTION)); // This removes the titlebar, you can leave that out

  SetWindowRgn(hWnd, hRegion1, true);

  DeleteObject(hRegion1);
end;
This is just an example I use at the moment.

The main thing is the CreatePolygonRgn.
Its first parameter is the start coordinate, the 2nd is the size of the array that includes the other point coordinates, the last one is the drawing method.

Should be easy to use in C++ as well.

Last edited by Kennung Eins; 08-12-2002 at 12:16.
   
Reply With Quote
Old
  (#20)
Andrew
Maha Guru
 
Andrew's Avatar
 
Videocard: Inno3D Geforce 8800GTS 512mb
Processor: Intel Core 2 Quad Q6600 (2.4GHz)
Mainboard: Abit F-190HD
Memory: 4Gb Corsair XMS2 800MHz
Soundcard: Onboard Realtek HD Audio
PSU: Antec 450W
Default 08-12-2002, 13:33 | posts: 1,463 | Location: UK

Quote:
Originally posted by Kennung Eins
Detonate, that idea is great.

I already thought of using the LoadImage function with the IMAGE_ICON parameter, so that it will load an icon.
This has the advantage that the pixel in the lower left edge of the pic will be used as transparent color for the whole picture.
This would work, although I didn't try it yet.

Mh...if the shapes would only be circles then we wouldn't have any problem, we could use the MakeCircularRegion function (or whatever this function was called)...

[edit]
ehm, I just tried this:
Code:
    hbitmap := HBITMAP(LoadImage(hinstance,'MyBitmap.bmp',IMAGE_BITMAP,0,0,LR_LOADFROMFILE or LR_LOADTRANSPARENT));
the loadtransparent is responsible for the effect I explained above, you don't need Icons for that (didn't know that yet).

It makes the lower left edge-pixel transparent, as well as all other pixels with the same RGB values.

[edit2]
mh but this only works with 8-bit BMPs... grrr...
That wasn't really my idea, take a look at Winamp3 in Win2k/XP

The only problem i can see with the method you used there is that you would get the 'jaggies' on the edge of the window. That and perhaps you wouldn't want the bottom left edge pixel to be transparent.

Edit>> Maybe you could read off the transparent colour's RGB or HEX value from a text file?
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com
Copyright (c) 1995-2012, All Rights Reserved. The Guru of 3D, the Hardware Guru, and 3D Guru are trademarks owned by Hilbert Hagedoorn.