Creating Custom Frames
Creating Custom Frames
Creating Custom Frames
Creating Custom Frames
Creating Custom Frames
Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames
Creating Custom Frames Creating Custom Frames
Creating Custom Frames
Go Back  Xtreme Visual Basic Talk > > > Creating Custom Frames


Reply
 
Thread Tools Display Modes
  #1  
Old 10-02-2012, 09:56 PM
RevertiveDeath RevertiveDeath is offline
Newcomer
 
Join Date: Jul 2012
Location: London, ON, Canada
Posts: 21
Default Creating Custom Frames


I need to be able to make a custom graphic frame with an array of custom buttons attached in my game. You can select different structures with their own build menus and I would like to make a custom frame with custom buttons created every time you click on one. How can I create a frame like this and a withevents array of custom buttons on top?
Reply With Quote
  #2  
Old 10-03-2012, 10:35 PM
hDC_0Creating Custom Frames hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 559
Default DirectX/non-DirectX game? Programmatically add controls at runtime & virtual controls

Just as a clarification/qualifier..

One of your two previous posts was in a non-DirectX Tower Defense game thread.
The other was requesting information for a DirectX game you were thinking of developing.
So I'm assuming this is about a non-DirectX question (since you didn't post in this time in the DirectX sub-forum).

For something like this the best "frame" is not a frame control but just a picturebox control.

I'm not quite sure what you mean by "build" menus, but let's assume they are just buttons calling some sub routine code.


When you say..
Quote:
Originally Posted by RevertiveDeath
..custom buttons created every time you click on one..
..I'm thinking you are talking about buttons programmatically created at runtime, perhaps?

Then you will probably want to look at the Add method of the Controls Collection (under VB6 its a collection not a class).
This "Create Controls Dynamically (VB6)" article gives you the basics.

And if you want to stuff a control (say a command button) into a picturebox control dynamically create at runtime
then you will probably have to do some runtime re-parenting of the button control (setting its Container property):
Code:
Set Command1.Container = Picture1


The other option is to use a picturebox as a button (known as the "pseudo-fakey" approach), or use a "virtual button".
Wondering where the code examples for these virtual button controls are?
Of course I could say "search the forum", but I'll be nice and give a link to the post where they are attached.

Pictureboxes are the "chameleon" of controls.
They can also be used for making the "thumb" of a fake slider control or for making shaped slider controls,
(based on the "How to: Fit a PictureBox to its non-transparent pixels" code).

The last "shaped slider controls" post (that I provided a link for) never got a screenshot attached,
so I'll attach a cropped one below.

Last edited by hDC_0; 10-03-2012 at 11:29 PM.
Reply With Quote
  #3  
Old 10-04-2012, 05:48 PM
RevertiveDeath RevertiveDeath is offline
Newcomer
 
Join Date: Jul 2012
Location: London, ON, Canada
Posts: 21
Default More clarity - Sorry

I actually finished the tower defence game and decided not to finish the direct x. Mci send string was better than DS. Anyways: I wanted to add something like what command and conquer has when you open a build menu it lets you select from structures/units. Some kind of easily reprogrammable virtual frame. I already have sufficient experience with form controls and "with event" controls but don't know how I would do this. I like the pseudo example and I also would like to make the "frame" semi-transparent

Last edited by RevertiveDeath; 10-04-2012 at 05:49 PM. Reason: Made more sense - added title
Reply With Quote
  #4  
Old 10-04-2012, 07:50 PM
hDC_0Creating Custom Frames hDC_0 is offline
Contributor

* Expert *
 
Join Date: Feb 2004
Posts: 559
Default Semi-transparent pictuerbox control as "frame"

Quote:
Originally Posted by RevertiveDeath
I like the pseudo example and I also would like to make the "frame" semi-transparent
Yeah, it is a pretty cool example (and I like it also of course ).

Here's the thing you've got to know right off - none of the common VB6 controls has in-built support
for semi-transparency (or any kind of alpha opacity adjust property).
Don't blame me (I'm just the messenger - send all your complaints to Microsoft).

So we're looking at workarounds.
There is an xvbt forum member, LaVolpe, who has has sub-classed controls and provided custom user controls with variable alpha opacity/transparency.

One example is his AlphaImage control.
I believe he also had an off forum thread where he adapted a picturebox to be a custom user control with semi-transparency as well.

The other option is you could (perhaps) also take the time to develop some
picturebox control subclassing yourself to create the semi-transparency effect.

If you don't want to deal with sub-classing and/or custom user controls, then the Windows API
that might prove helpful is the SetLayeredWindowAttributes API.

It's designed for a Windows' windows.
Under VB6 a form is a Windows' window.
However, any of the controls that has a hWnd (handle to a window) property can be
considered a window as well (but in a special ThunderClass-derived sense).

The difficulty is that when a picturebox is contained inside a form it has to follow the windows properties of the form,
so generally the picbox transparency examples I've seen re-parent the picturebox to the desktop (device context 0)
before adjusting the picbox's "window" attributes or "style" (GWL_EXSTYLE).

This creates a a kind of "float" picturebox window with semi-transparency (see
attachment below - note: I don't usually like to do code attachments,
but there was no code, that did what I want, which I could reference elsewhere).

Then you have to find a way to re-parent the picturebox control to the form in such a way that
the semi-transparency effect isn't destroyed
(and usually requiring the position of the picturebox is adjusted accordingly,
from "screen" to form coordinates),
or,
you can set up a timer loop to continually adjust the "float" picturebox window
to stay within the bounds of the form when it moves
(without taking the step of re-parenting back in to the form).

Anyway, have fun..it would be nice if you could post some kind of faked-up screenshot --I'd like
to get an idea of how the build menus are supposed to look and act..for instance
are they drop down menus? will they have some texture applied?)
Attached Images
File Type: jpg screenshot_transparent_VB_picbox_control.JPG (18.1 KB, 7 views)
Attached Files
File Type: zip transparent picturebox_control_test.zip (35.1 KB, 23 views)

Last edited by hDC_0; 10-04-2012 at 08:06 PM.
Reply With Quote
  #5  
Old 10-04-2012, 11:09 PM
RevertiveDeath RevertiveDeath is offline
Newcomer
 
Join Date: Jul 2012
Location: London, ON, Canada
Posts: 21
Default

I will paste images when I start getting more detail into them. ATM they are no better than drawing one with keyboard characters. They aren't exactly drop down because it requires a click beforehand and for this project I'm using a threaded loop so anything timer related will be fine for me. Possibly add it where I paste all graphics to the form and add a separate function for creating "menus" and I'll add fake command buttons with the pic as container/parent
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Creating Custom Frames
Creating Custom Frames
Creating Custom Frames Creating Custom Frames
Creating Custom Frames
Creating Custom Frames
Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames Creating Custom Frames
Creating Custom Frames
Creating Custom Frames
 
Creating Custom Frames
Creating Custom Frames
 
-->