473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Win32 API Graphical Controls - How to Redraw

I'm working with VBA for Excel 2003. I created UserForm1 and added a command button. I can manipulate the properties of UserForm1 using the form's hwnd. For example, I stripped the border, max/min, and caption properties. I'd like to create the same uniform look for child controls such as the button but graphical controls don't have handles. Is there a way to redraw graphical controls using the API? Thank you for your input.
May 24 '13 #1
5 3389
Oralloy
988 Expert 512MB
tbostwick,

My suggestion is that you use the attributes for UserForm1 to control it's look and feel. Try to stay within the capabilities of VBA, rather than using calls to the Win32 API. The controls that you put down have similar attributes that you can manipulate.

Since most attributes can be manipulated at design time, they will be saved when you save the spreadsheet, there is then no need to override them through the Win32 API.

Hope this helps,
Oralloy
May 26 '13 #2
Hi Oralloy: Thank you for your reply. Issue #1 is that VBA allows very little customization of controls. For example, you can't remove the close 'X' or change the border without calls to the API. Issue #2 is that graphical child controls such as a command button aren't windows and don't have handles so you can't modify them using the same API calls that modify the form. Which leads to Issue #3, How do you control how graphical controls are drawn? This seems to be a pretty major issue with Windows development so there must be an answer.
May 28 '13 #3
Oralloy
988 Expert 512MB
tbostwick,

First, a proviso - my full-up Office-pro system died a virus death a little while ago, and I gave it to my kid as an excuse for my new toy. Thus, I am working from memory today. If I am wasting your time, tell me, please.

Yes, issue #1 is a pain in the tail, especially if you want to change window styles on the fly. That said, my experience in composing relatively small applications is that the available functionality was adequate to my needs. I'm not sure what you are facing, but all of the principle window styles should be available.

Also, you might try setting the BorderStyle property of your form (in the forms editor) to 0 or 1 (borderless or thin, respectively). The 2003 reference I found is here.

Another sleezy trick you might use is this, but it really isn't professional at all:
Expand|Select|Wrap|Line Numbers
  1. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  2.   If CloseMode = vbFormControlMenu Then
  3.     Cancel = True
  4.     MsgBox "Please use the Close Form button!"
  5.   End If
  6. End Sub
Issue #2 is a pain - I know that you don't have a lot of control over most aspects of the "controls", although you can get a list of the available messages that they can process by using VBA's editor's drop-down. Looking around, I found this old example for graphic controls, which might help for pure graphical manipulation. It kind of stinks that we have to break out into the Windows API, rather than having some degree of native competence in VBA.

The example above is for VBA 6, however I think that it might help you with your issue #3.

Kind Regards,
Oralloy
May 28 '13 #4
Again, thanks very much for your detailed reply. The example you linked to looks promising, along the lines that I suspected would be required. I'll dig in and see what happens. Thanks again! --Tim
May 28 '13 #5
Oralloy
988 Expert 512MB
Tim,

I'm glad that helps you some. I know the reference is dated, but VB hasn't changed all that much over time.

May I ask what you are trying to achieve in terms of look, feel, and behaviour of the application you're working on?

--Oralloy
May 29 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RL | last post by:
Hello Perl gurus, 1. I have a web page where I can push a button (dospawn.html). 2. This button calls a CGI script (spawnboss.cgi) 3. spawnboss.cgi calls a forking perl script (forkme.pl) 4....
10
by: Charles Law | last post by:
I have a user control created on the main thread. Let's say, for arguments sake, that it has a single property that maintains a private variable. If I want to set that property from a worker...
2
by: Jose Michael Meo R. Barrido | last post by:
I made a custom runded rectangle usercontrol. I used a function i found on the internet. the function works fine(see "GetRoundRect" below). I use the fullowing code to make my usercontrol...
2
by: conset23 | last post by:
Hello. I'm working with WinForm. It has 30 same user control, each with 4 buttons, 3 labels, 3 textboxes, 2 picture boxes and uses override onPaint to draw gradient rectangle. Main form also has 2...
1
by: Mau | last post by:
I ' m looking for some articles concerning the way to create graphical controls in ASP.NET or WinForms an example: I would like to create a round progress bar and so on..... I think that I...
5
by: John Smith | last post by:
Hello Coould please any one to help me to find good graphical controls to create GDI in ASP.NET. Some related websites also really appreciated Thanks in Advance John
2
by: diogoko | last post by:
I have some code like: try { someButton.disabled = true; cpuIntensiveCode(); } finally { someButton.disabled = false; } The problem is that someButton is never disabled, because the browser
8
by: George | last post by:
Hello everyone, I am using C# on a Pocket PC 2003 project based on .Net Compact Framework of Visual Studio 2005. I want to re-draw some controls of a Form (Window) at a regular interval (for...
4
by: Joergen Bech | last post by:
Just out of curiosity: What is your favorite method of making sure that anything that happens on a form, only happens in response to a single, external event? Take the example below. I have made...
1
GaryTexmo
by: GaryTexmo | last post by:
In my last insight, http://bytes.com/topic/c-sharp/insights/909141-object-scaling-varying-resolutions, I talked about scaling objects to a form's size so that it would always draw with the correct...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.