Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

How can I change screen backgrounds on the fly


Recommended Posts

Not being very experienced in visual basic/C, How would I go about creating a (C-hook/VB ) that will allow me to set 2 screen backgrounds and change them on the fly in VX. I prefer the gradient background for my solid but when I'm sketching geometry I prefer the plain black. In some design packages like (Pro-E)the background will change automatically from sketching mode to modeling mode.

Link to comment
Share on other sites

To get you started, from the file GrVars_CH.h in the c-hook sdk:

code:

/**

* @defgroup gr_grp9 Graphics Background Gradient Defines

* @{*/

#define GRADIENT_NONE 0 ///< None (use Graphics background color)

#define GRADIENT_HORIZONTAL 1 ///< Horizontal

#define GRADIENT_VERTICAL 2 ///< Vertical

#define GRADIENT_DIAGONAL 3 ///< Diagonal

/** @}*/

 

extern DllImpExp MC_BYTE gr_back_color; ///< graphics view background color

extern DllImpExp MC_BYTE gr_gradient_start_color; ///< graphics view gradient start color

extern DllImpExp MC_BYTE gr_gradient_end_color; ///< graphics view gradient end color

extern DllImpExp short gradient_direction; ///< graphics view gradient direction

You may need to call repaint_graphics(); or rebuild_graphics(); after changing the values.

 

Bryan smile.gif

Link to comment
Share on other sites

For your enjoyment and maybe education? wink.gif

A CHook to switch the Graphics Background “on the fly”.

 

Since Bryan so thoughtfully looked up all the needed info. smile.gif

I thought hmmm… What would this look like?

 

In the C-hooks folder on the forum FTP site, you’ll find -> GraphicsBackground_CHook.zip

 

It addition to containing the GraphicsBackGround.DLL and GraphicsBackGround.FT (what is needed to run this add-on).

The entire VS2003 C-Hook project with source code is included!

 

To use the CHook:

Copy the DLL and FT files into your CHOOKS folder and restart X.

Now in Settings-Customize, under the Category: "C-Hooks" you’ll find 2 new icons;

1 sets the background to ‘plain’ and the other sets it to ‘gradient’.

As you can see by the icons that I’m no artist. It would take me as long to make ‘pretty’ icons as it did to create the entire project!

 

NOTE:

I’ve included a method of defining the color of the non-gradient background using the PARAM option in the FT file, which of course does not require rebuilding the DLL.

But the gradient option requires more than one value, so you will need this project, as rebuilding the DLL is the only way to alter the colors used in the ‘gradient’ mode. You could certainly find a way to obtain those (2) color settings and even the gradient direction by storing that data “somewhere” (text file, the Registry, etc) and having the GraphicsBackground CHook read that data each time the ‘gradient’ mode is executed.

I leave that task to you…

 

A few notes on using the VS project files:

 

1>

You may need to alter the ‘Additional Include Directories’ paths in the Project since I have the SDK installed at C:SDK and you may have it somewhere else on you system, such as C:MCAMXSDK. Hint! An easy way to change all those paths is not do it using the Project Properties Pages inside VS, but just directly edit the GraphicsBackGround.vcproj file in a text editor and do a mass search and replace.

 

2> If your Mastercam X is not installed in C:MCMAX-MR2 (like mine), you’ll need to alter the InstallRelease.bat and InstallDebug.bat files to set the destination folder to be correct for your system’s setup.

 

 

Happy coding! zDog

Link to comment
Share on other sites
  • 2 weeks later...

Zerren Gedeon,

 

I've used your code as basis for a chook and I wish to put my chook and code up on the ftp site but I didn't see any kind of licensing stated in your files. Since my code is partially derived from your code do you have any problems with me putting this up? Are there any licensing statements you wish me to include? (ie GPL?) Or can I put a general 'public domain' 'do what you want' on it?

 

Bryan smile.gif

Link to comment
Share on other sites
  • 2 weeks later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...