
headkaze
Members-
Posts
23 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by headkaze
-
Take a look at the SplitContainer under Containers. Drag your DataGrids onto these and "Dock" them appropriately. Docking should ensure that resizing the window will have them adjust accordingly. Also consider that the zorder of controls can effect how they will be docked, so you can also right-click controls on your form and select "Bring To Front" to effect the positioning.
-
I would ask someone at your local electronics store if they have kits for something like that. You might want to consider controlling a device through a COM port or perhaps there are devices that already have their own software and way to communicate via a computer. This is why you really need to look around at the devices out there on the market, then the manual that comes with it should explain how to communicate to it. I'm guessing digital combination locks could be quite expensive.
-
Getting a value using a column name instead of index
headkaze replied to headkaze's topic in Database / XML / Reporting
-
Changing Soundcard properties
headkaze replied to melkanzi's topic in Interoperation / Office Integration
You will probably have to use pinvoke for that or write a wrapper and C++ dll. Check out the code for Program 4. Microphone Select -
You may be able to modify the following code to measure the height of a tooltip. public static void AutoSizeLabelHeight(Label ctlLabel) { Graphics g = ctlLabel.CreateGraphics(); Font font = new Font(ctlLabel.Font.Name, ctlLabel.Font.Size, ctlLabel.Font.Style); StringFormat sf = new StringFormat(); SizeF stringSize = g.MeasureString(ctlLabel.Text, font, ctlLabel.Width, sf); ctlLabel.Height = (int) stringSize.Height + 2; g.Dispose(); font.Dispose(); sf.Dispose(); }
-
I am writing a simple PhoneBook database program, and part of it requires me to get the values of the currently viewed record. I am using BindingManagerBase to handle browsing through the Phone Book. Right now I am using the following line to get the value of column 0 ("Phone") to retrieve the phone number of the currently viewed record. dataSet11.Tables["PhoneBook"].Rows[this.bindManager.Position].ItemArray[0] I am wondering, can I possibly get the value like ItemArray[] but using the column's name. The above line gives me the value of "Phone". But I would like to use the columns name "Phone". Eg. ItemArray["Phone"], but obviously that only accepts a int index value. I can't seem to find a simple way to do it.
-
Just create a method that will search for the Id... Product GetProduct(int id) { foreach(Product p in ProductArray) if(p.Id == id) return p; return null; } Product MyProduct = GetProduct(3); Debug.WriteLine(MyProduct.Name);
-
Maybe have an image list with your frames of animation and use a picturebox with a timer that changes the images.
-
blitting with bitblt, again
headkaze replied to snarfblam
's topic in Interoperation / Office Integration
I know this is an old thread, but I found this use of bitblt in C# on the web a while ago if it's of any help. public static void DrawBitBlt(Graphics g, Bitmap bmp, ref Rectangle destRec) { IntPtr hDC = g.GetHdc(); IntPtr hBmp = bmp.GetHbitmap(); IntPtr ImageDC= a.Api.CreateCompatibleDC(hDC); IntPtr offscreenDC= a.Api.CreateCompatibleDC(hDC); IntPtr drawBmp= a.Api.CreateCompatibleBitmap(hDC, destRec.Size.Width, destRec.Size.Height); IntPtr oldBmp= a.Api.SelectObject(ImageDC, hBmp); IntPtr oldDrawBmp= a.Api.SelectObject(offscreenDC, drawBmp); if(bmp.Size.Equals(destRec.Size)) { a.Api.BitBlt(offscreenDC, 0, 0, destRec.Width, destRec.Height, ImageDC, 0, 0, SrcCopy); } else a.Api.StretchBlt(offscreenDC, 0, 0, destRec.Width, destRec.Height, ImageDC, 0, 0, bmp.Width, bmp.Height, SrcCopy); a.Api.BitBlt(hDC, destRec.X, destRec.Y, destRec.Width, destRec.Height, offscreenDC, 0, 0, SrcCopy); a.Api.SelectObject(ImageDC, oldBmp); a.Api.DeleteObject(hBmp); a.Api.SelectObject(offscreenDC, oldDrawBmp); a.Api.DeleteObject(drawBmp); a.Api.DeleteDC(ImageDC); a.Api.DeleteDC(offscreenDC); g.ReleaseHdc(hDC); } -
I had a similar problem with autosizing the height of a label depending on it's contents. I'm not sure if it will be of any help, but cags posted some nice and simple managed code to do it. Here it is as a class: public class AutoSizeLabel { public static void AutoSizeLabelHeight(Label ctlLabel) { Graphics g = ctlLabel.CreateGraphics(); Font font = new Font(ctlLabel.Font.Name, ctlLabel.Font.Size, ctlLabel.Font.Style); StringFormat sf = new StringFormat(); SizeF stringSize = g.MeasureString(ctlLabel.Text, font, ctlLabel.Width, sf); ctlLabel.Height = (int) stringSize.Height + 2; g.Dispose(); font.Dispose(); sf.Dispose(); } }
-
I'm quite confused about the way ComboBox's FindString() method works. Consider the following example: ComboBox myComboBox = new ComboBox(); myComboBox.Items.AddRange(new string[] { "Test1", "Test2", "Test3", "" }); MessageBox.Show(myComboBox.FindString("Test1").ToString()); MessageBox.Show(myComboBox.FindString("Test2").ToString()); MessageBox.Show(myComboBox.FindString("Test3").ToString()); MessageBox.Show(myComboBox.FindString("").ToString()); The first three output as you would expect 0, 1, 2 but the last one output's 0. ***? Who wrote this method anyway. I mean I could understand it returning -1 or something like that but it is returning 0 which is "Test 1" which is not null, and not an empty string "".
-
I'm writing a configuration program and I need to get a list of DVD MPEG-2 codecs on the machine. The same list you get from the program DecCheck Eg. NVIDIA Video Decoder Leadtek Video/SP Decoder Is there any way to do this using managed code? I assume it might be a bit difficult for .NET's lack of DirectShow support. Perhaps I can use DirectShowLib or something, but it would be nice if I can do it in my own class without a dependancy even if I have to use p/invoke.
-
Thanks for that
-
I've done quite a bit of searching and most pages on the NET point to an article that is no longer available.. http://www.omniscium.com/index.asp?page=DotNetScreenResolution I can view the article fine on archive.org, but it would be nice to have the Resolution.zip file that was hosted on the site and is now a broken link. http://web.archive.org/web/20050227032111/http://omniscium.com/index.asp?page=DotNetScreenResolution Does anyone here have that file who can re-post here? It would save me some time writing my own class for it.
-
All that hoohaa was just to split up the text in the TextBox into an array of words separated by a space, then bring them back together placing a "+" between them. myTextBox.Text = "word1 word2 word3"; MessageBox.Show(String.Join("+", myTextBox.Text.Split(' '))); Will ouput "word1+word2+word3". The error you got was because I accidently used single quotes for a char in the Join method when it expects double quotes for a string.
-
If you have a look at the url of a site like Google after a search you can see what variables are used to POST to their engine. Eg. Typing "word1 word2 word3" into Google results in: http://www.google.com.au/search?q=word1+word2+word3 If you take this as a reference you can take your TextBox text and create a url for it. Eg. string myURL = "http://www.google.com.au/search?q=" + String.Join('+', myTextBox.Text.Split(' ')); Then send myURL to your browser control and it should show google with the words from your TextBox.
-
Rather than wait for the process to end use Exited event to find out when the process has ended, that way messages can continue processing while the process has been launched. internal void ProcessExited(object sender, System.EventArgs e) { ((Process)sender).Close(); MessageBox.Show("Mame Process has ended"); } private void Button_Click(object sender, System.EventArgs e) { Process myProcess = new Process(); myProcess.StartInfo.FileName = "mame.exe"; myProcess.StartInfo.Arguments = listView1.SelectedItems[0].Text; myProcess.EnableRaisingEvents = true; myProcess.Exited += new System.EventHandler(ProcessExited); bool ret = myProcess.Start(); }
-
This is what I was afraid of. It annoys me there is no built in collection class that has the two features I need. I think I'll need to use inheritence on the HashTable class and add some extra methods, or override like you said. Oh well, thanks for the reply.
-
My label resizing class won't work with bold font
headkaze replied to headkaze's topic in Graphics and Multimedia
-
A Hashtable is perfect for storing a section of an ini file in memory because it has the key/value combination like an ini file. So I wish to use a Hash table but there are two features of a Hashtable I don't like. 1. ht["name"] is not the same as ht["Name"] (ie. Case sensitive). For an ini file this is bad because ini files don't need case sensitive text to work. In this case I can't have this case sensitive. 2. Enumerating a hash table wont return the items in the order they were added: Eg. IDictionaryEnumerator en = ht.GetEnumerator(); while (en.MoveNext()) { MessageBox.Show(en.Key + "=" + en.Value); } While it's not important that I have the items enumerated in the order I add them it would be preferable because creating a new ini file would allow me to write to it in the same order I read them. Is there something like a Hashtable that will allow me to have the two features above? Thanks in advance for any help.
-
My label resizing class won't work with bold font
headkaze replied to headkaze's topic in Graphics and Multimedia
-
My label resizing class won't work with bold font
headkaze replied to headkaze's topic in Graphics and Multimedia
Found the solution to this problem... changed the following line: myLabel.Font = new System.Drawing.Font("Verdana Bold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); Notice, the name of the font is now "Verdana Bold". It seems you need to specify bold in the name for it to measure a bold font properly :rolleyes: -
My label resizing class won't work with bold font
headkaze posted a topic in Graphics and Multimedia
Hi, my first post to the boards so hello! :) I've written a class that will auto size the height of a label based on the text inside. It works fine for normal text, but if I make the text bold it seems to ignore that it's bold and still measure the label as if it was regular text. This means it won't resize the label properly. I have to have this working for bold text! Does anyone have any ideas how I can modify it to work with bold text? public class clsAutoSizeLabel { [DllImport("gdi32.dll")] private static extern bool DeleteObject(IntPtr hObject); [DllImport("user32.dll")] private static extern int DrawText(IntPtr hDC, string lpString, int nCount, ref RECT lpRect, uint uFormat); [DllImport("gdi32.dll")] private static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); private struct RECT { public int Left; public int Top; public int Right; public int Bottom; } private const int DT_CALCRECT = 0x400; private const int DT_WORDBREAK = 0x10; public static void AutoSizeLabelHeight(Label ctlLabel) { RECT uRECT; uRECT.Left=0; uRECT.Top=0; uRECT.Right=0; uRECT.Bottom=0; try { Graphics objGraphics = ctlLabel.CreateGraphics(); IntPtr hDc = objGraphics.GetHdc(); IntPtr hFont = ctlLabel.Font.ToHfont(); IntPtr hFontOld = SelectObject(hDc, hFont); uRECT.Right = ctlLabel.Width - 4; if(DrawText(hDc, ctlLabel.Text, -1, ref uRECT, DT_CALCRECT | DT_WORDBREAK) != 0) ctlLabel.Height = uRECT.Bottom + 4; SelectObject(hDc, hFontOld); DeleteObject(hFont); objGraphics.ReleaseHdc(hDc); objGraphics.Dispose(); } catch { } } } Here is an example of how I would call the method. If I change it from bold to regular the measurement is the same. myLabel.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); myLabel.Location = new System.Drawing.Point(168, 8); myLabel.Name = "myLabel"; myLabel.Size = new System.Drawing.Size(432, 32); myLabel.Text = "This is the text inside the label, but it dosn't seem to work properlly when I use bold!"; myLabel.BackColor = System.Drawing.Color.Blue; // set background to blue so we can see the sizing properly clsAutoSizeLabel.AutoSizeLabelHeight(myLabel); this.Controls.Add(myLabel);