|
I wonder whether the following would explain the reason (at least partially):
I tried to dig inside the disassembler for the System.Windows.Forms.dll file with ildasm. Also tried through a simple project. I started with a button size of 22,22. After clicking on the buttons collection property, in the ToolBarButton Collection Editor, what one notices is that the non-editable value of the Rectangle property for the first button is 0,0,23,22 (meaning that the size is 23,22) if the Style property is "PushButton". However, the moment one chooses the Style property as "DropDownButton", the said Rectangle property immediately becomes 0,0,36,22 (meaning that the size property is 36,22). Thus, a change of Style from PushButton to DropDownButton change the Height of Button from 23 to 36. It appears to be a read-only internal setting, though I am not very sure. I wonder whether this is a partial explanation.
After a slightly deeper research in the disassembler of toolbar class in the said dll file, for example, one notices that in the ToolBar::get_ButtonSize method, the button size is automatically set to either 39,36 or 23,22 depending upon the "Underneath" or "Right" values (respectively) of the TextAlign property of the button. Apparently, something similar is taking place in the internal coding of the said class when the Style property is being changed. Though, I must admit that I could not reach at the proper code after my limited research in the disassembled class structure. Perhaps some more study will reveal the secret of this behaviour.
I really do not know of what help, if at all, the above discussion would be to you...!
|
|
|
|
|
Just as I was finishing the reply, there was a power failure and I lost it all!
So, here's again in a more summarized way:
I also looked at the dissasembly using .NET Reflector, and indeed found the same you did: that the ToolBar.ButtonSize property always returns a fixed size, depending on TextAlign . And neither I could find where the height is changed for a DropDownButton .
Sometime ago I asked here about setting the width of the buttons to be just enough for the text, and not always the same. Looking at the disassembly, there's a ToolBar.ForceButtonWidths internal method that doesn't let the user do that. But also, each ToolBarButton has a Width internal property that returns the calculated minimum width for the button.
This article[^] in MSDN says that all the toolbar buttons must be the same size, but there's the TB_SETBUTTONWIDTH[^] message which lets you set the minimum and maximum width of a button.
Additionaly, the TB_SETUBUTTONINFO[^] message appears to let you set the width through the cx field of the TBBUTTONINFO strucrure (which the .NET ToolBar control uses extensively.) But there's nothing to set the height (maybe TB_SETBUTTONSIZE before adding any buttons could work).
Well, I guess this would make for a great CP article. I'll look into it when I have some free time. For now I should better get back to work.
Thanks for your time!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hello,
I am trying to find a faster, better way to know when something on the desktop changes. Could be application focus, text being typed, time in the systems tray changes..anything.
Instead of using a screenshot and figuring out the difference. Isnt there a way to tap into the desktop update events? Kinda like you hook into the mouse and keyboard events?
I know there are some custom video drivers out there that vnc uses. But I dont think thats something that can be used in C# affectivly.
Any suggestions or comments?
thanks
Steve
|
|
|
|
|
|
There are many different "events", as you call them, that get "fired" when something on the desktop changes. They're really window messages, but there so many different ones depending on what's going on, that you'll really find it difficult to capture all these changes.
What's the goal here? What are you really trying to accomplish?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the replys.
My main goal is to find a faster process to grab screen changes. Instead of using the whole take 2 bitmaps and compare method.
Going through tightVNC's code, they are hooking that video driver then checking the messages for an update, grabbing the region and sending it..genius.
Now if only I could tap into that somehow, my cpu would go down and my process time would be faster.
Steve Welborn
Software Architect
|
|
|
|
|
I have an application that connects to a Web Service.
When I clicked a button to open a form "A", at the same time I stopped the Web Service in IIS - this stopping action raised an event - this event will close all opening forms by calling Dispose() method of each form.
Because the form "A" was processing CreateHanlde() method when it was disposed, it threw following exception:
"An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll
Additional information: Cannot call Dispose() while doing CreateHandle()."
==> How do I solve this problem ?
Giang Nam
|
|
|
|
|
Why is your WebService firing an event to trigger forms to close?
Why are you creating a form only to have it be killed off by this event? Wouldn't it be easier to create the form AFTER the WebService is shutdown? What does this form have to do with the WebService?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
- That's a Chat application.
- Every period of time, I call a method of Web Service to get messages sent to me. This is done by a Timer.
- When the Timer ticks, my application call that method but 'cause the IIS has been stopped, it throws an Exception.
- I catch this Exception and raise an ServerError event, this event will close all opening windows and ask User if he want to relogin.
==> Because, this event disposes all windows while one of them is calling CreateHandle() method, it throws above Exception.
==> That's my problem, thanks for answering me.
|
|
|
|
|
Hi, i want to get the file properties dialog of multiple files to show up in c#; same as if you were to select multiple files in explorer and hit properties. If someone could point me in the right direction id be thankful.
|
|
|
|
|
|
I've had no problem, so far, constructing object and structures that have constructors, however, from past experience, I have encountered struct objects (usualy COM) that do not have constructors.
All their values are initialised to zero, null, etc, by default, and their values are set individualy in public fields.
How would I create a new object of this type via reflection?
With code, i would simply declare a variable of that type and set the values, but this is an entirely different situation.
Cheers
Cata
|
|
|
|
|
Every object has a default constructor, unless it's explicitly made private, in which case, it's designed to be created by a factory method. You'll need to find the method and call it, I'd have thought.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Have a look at RSAParameters in .Net Reflector. The entire struct is just made up of public field members.
No constructors, methods, or properties.
There are a number of these objects that are in the .net library, and i'd like to know how to create an instance. From tinkering with COM i gather most objects of this type are used in marshaling.
And while i'm at it, what about int16/32/64 etc? I know I can parse them from a string but is there anyway to create an instance directly of a particular value?
Cata
|
|
|
|
|
Can anyone suggest how I can capture any packet that is sent from a host? The idea is to not let the packet out into the network, but to capture it, generate our own reply and send it back to the host. If I have the packet, I know how to strip it into the various layers and make a new one to send back. The problem is actually getting the initial packet.
I've looked at sniffer source code but that seems only to look what packets are on the line and not physically take them. Someone said that I should use a NIC in promiscuous mode? As far as I know, a NIC in promiscuous mode will listen to any packets on the network, not just ones destined for its own interface. I only want to capture the packets from the host that the application is running on and not from any other machine on the network. To try make this clearer, when the application is running, the host will not be able to communicate over the network but instead will only be able to communicate to the application.
Any help or pointers in any direction will be greatly appreciated!
Thanks!
|
|
|
|
|
Well, one problem you have is that Raw Sockets are restricted to Administrator use only. Normal users can't create packets from scratch...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the response! The application will be used in a classroom where each student will be running a server, so the Admin use is not a problem.
|
|
|
|
|
Hi,
I put a combobox on my winform C# and each time the user touch by mistake the mouse scroll wheel it gives another selection in the list and that's what I would like to avoid.
Is there a property where I can cancel the scroll wheel for the combobox?
Thanks for your help
from a beginner
|
|
|
|
|
No, there isn't.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
There's no property to use, but you can subclass a ComboBox and stop the scroll wheel message (WM_MOUSEWHEEL ) from getting through by overriding the WndProc [^] method
public class ComboBoxEx : ComboBox<br />
{<br />
public ComboBoxEx() : base()<br />
{<br />
<br />
}<br />
<br />
<br />
protected override void WndProc(ref Message m)<br />
{<br />
if (m.Msg == 0x020A )<br />
{<br />
return;<br />
}<br />
<br />
base.WndProc (ref m);<br />
}<br />
}
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
Hi Mathew,
Thanks for your code. Easy and it works fine.
Regards,
Davy
|
|
|
|
|
No worries
"I think I speak on behalf of everyone here when I say huh?" - Buffy
|
|
|
|
|
How can i hide or remove 1 or 2 of the buttons (next/previous month) in the MonthCalendar Control ?
Is there a way to do it ?
|
|
|
|
|
I don't think it's possible, the MonthCalendar control is a wrapper around the SysMonthCal32 common control and I don't see that as an option in the native control.
James
|
|
|
|
|
Hi all,
I am trying to achieve the same behavior as the FlowLayoutPanel control found in .NET 2.0, but with our current .NET 1.1 project.
Anyone knows of a 3rd party control that can do that?
Thanks!
|
|
|
|
|