|
aToolTip.Show(Trackbar.value.toString(), Me.Parent, New Point(x position, y position))
|
|
|
|
|
Hi,
I'm new to event handling in C#. I'm writing a windows service and i want a configuration form opens when user press a shortcut(like Ctrl + Alt + F12). I tried event handling and delegates but when the form had no focus it didn't work.
I want to know how i should listen for keyboard events when i have just a windows service or a form without focus. any help is really appreciated.
Thanks in advance
Sadeghi
MSK
From Persia, the land of Love and Freedom
|
|
|
|
|
|
Hopefully someone here can help.
I've got a picturebox control with scrollbars. I've also set it up so that I can click on the picture box that has an image and draw a box border by dragging the mouse to whatever dimensions I want the box to be. It's basically a utility program for setting up hotspots on an image that will be saved into an array. This part works perfectly.
The problem is that if I scroll the image up or down so that the offset might be then try to draw my box, the image starts to do some flickering with it bouncing back and forth with how the image should be displayed (let's say an offset of X = 100, Y = 100 - which is what it is supposed to be since I have moved the image over with the scrollbars) and bouncing back to the default position (X = 0, Y= 0)
I've got this bit of code in my hScrollbar1_Scroll, vScrollbar1_Scroll, PictureBox_Paint, and Form1_Paint events:
Graphics g = pictureBox1.CreateGraphics();
g.DrawImage(pictureBox1.Image,
new Rectangle(0, 0, pictureBox1.Right - vScrollBar1.Width,
pictureBox1.Bottom - hScrollBar1.Height),
new Rectangle(hScrollBar1.Value, hScrollBar1.Value,
pictureBox1.Right - vScrollBar1.Width,
pictureBox1.Bottom - hScrollBar1.Height),
GraphicsUnit.Pixel);
Somewhere there is an event that is showing this image in the default position of 0,0 and it's not taking the values from the Scrollbars into consideration.
I am using picturebox1.Invalidate(); whenever I am drawing on that surface which I am *assuming* triggers the paint event(s).
|
|
|
|
|
May I see a snapshot? I have somewhat a hard time picturing it. Also, are you saying the above code is in hScrollbar1_Scroll, vScrollbar1_Scroll, PictureBox_Paint, and Form1_Paint events. All of the events have the same code?
|
|
|
|
|
Not sure how to attach an image to this short of posting it elsewhere and linking to it, but hopefully this will help:
****************************
* * *
* B * A *
* * *
*********** *
* ************
* * *
* * C *
* * *
****************************
A represents the overall bitmapped image.
B represents the size of the picturebox and what part of the bitmapped image that shows in the default (0,0) position.
C represents what part of the bitmapped image is showing in the picturebox when the image has been scrolled to its farthest right and bottom. NOTE that C can be anywhere depending on how far you have scrolled the horizontal and vertical scrollbars.
The problem is that when, for example, I am in the C section, if I try to draw my box there (MouseDown, MouseMove, and MouseUp Events), the image will flicker back and forth between the B & C positions. At the end of my MouseDown, MouseMove, and MouseUp events, I am invalidating the picturebox to force the picturebox_Paint event, so there is no reason that the picturebox should be going back to the B position.
I did manage to resolve this issue however. Turns out that it was the Invalidate that was messing things up. I *assumed* that PictureBox.Invalidate forces the Picturebox_Paint event. What it apparently was doing was redrawing the image in the picturebox based on default settings, THEN calling PictureBox_Paint, which told it to paint the section based on the positions of the scrollbars. Net result was flickering back and forth between the 2 positions. Maybe my explanation here is incorrect, but getting rid of the Invalidate command and parking that code (drawing the image based on the scrollbars position) in there instead fixed the problem. No flicker and the image stays put.
Woot! Onward and forward...
|
|
|
|
|
Overall, I think it would be easier to abandon the picture box and just do all this in your own paint event.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I've been searching for how to do this for quite awhile, so please forgive me if the answer is easy.
I have a DataGrid displaying numbers and based on the value of number the cell is formatted (e.g. ForeColor). I use Clipboard.SetDataObject(dataGridMatrix.GetClipboardContent()); to copy the DataGrid (ClipboardCopyMode has been enabled).
When I paste into Excel, i get the values as expected but with no formatting.
Is there a way to copy the formatting?
My understanding is the grid is copied as HTML which could contain formatting and which I know Excel is capapable of interpreting.
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Hey,
until now I've only used the .Net Framework but I need an Interface of the Shell32.dll to read Windows .Ink files.
I've spent some time now trying to figure out how that works but I only found webpages describing how to call DLL functions and one that gave me huge amounts of information that I didnt understand ;-(
(In this case it's IShellLink Interface)
Can anyone give me some hints how to do this?
|
|
|
|
|
|
Wow, thanks a lot!
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks for a great link!
|
|
|
|
|
Wow, what an old thread. Always happy to help you Luc!
|
|
|
|
|
I've written a plug-in architeture based application. Plugins exist in isolated assemblies and each plugin runs in it's own thread provided by the host application. But these plugins just cannot display their own forms. Exactly, they can, but it's just a "flash". How can I deal with this?
Herewith the working model:
All the plugins implement the interface IPlugin. The host start the plugin through the method in IPlugin with a new thread. The plugin begin its work as is required(this is where I want the plugin shows its form). The plugin trigger an event while the progress changed. When the task is done, the host will destroy the instance of the plugin.
thanks in advance...
modified on Sunday, May 11, 2008 10:57 AM
|
|
|
|
|
For a UI application to run in its own thread it probably needs a message pump and a UI thread.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Could you please give please give more details?
I'm not so good at messages..
Thanks.
|
|
|
|
|
I solved it in a tricky way....:
<br />
_CurrentPlugin.Window.ShowDialog(this);<br />
|
|
|
|
|
Hi all,
I'm trying to open an existing Excel file using Excel, from my C# application.
I've managed doing so using the following code:
Excel.Application excelApp = new Excel.Application();<br />
Excel.Workbook workBook = excelApp.Workbooks.Open(strFileName, 0,<br />
false, 5, "", "", true, Excel.XlPlatform.xlWindows,<br />
"\t", false, false, 0, true, 1, 0);<br />
excelApp.Visible = true;
However, I'm facing the following problem: Opening the file using this code creates a new process - EXCEL.exe, which doesn't ends after closing the Excel application!
What am I doing wrong?
Thanks a lot,
Eyal.
|
|
|
|
|
|
If you just want to display the file then how about:
System.Diagnostics.Process.Start(strFileName); That'll just launch the default viewer for the filename.
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
|
System Error mgs and flickering issue....
Hi Guru,
I want your help,
In my media application I get some errors saying “If you were in the middle of something, the information you were working on might be lost..” I cant trace the exact error, now it is big headache for me. I you guys know any solution for this please help me. In my application no any windows functionality j’t have Global hook (keyboard and mouse) , communication between AMX and PC using tcp/ip socket programming. And if application or PC hang (stuck) I rebooted it auto by watchdog so I am having lot of things in this proj that why..
Another problem ,..:
It is also from same application in there having some TV / DVD / VOD /AUDIO all entertainment things doing wn32 and using grabber controls which are to show the movies. So what I getting is when I close the TV it get flicker between my home page and TV grabber controls. These two are major issue for me and no any solution.
Please consider abt tht and help me.
Your corporation is appreciated!
Anushka
|
|
|
|
|
Hello everyone,
I am migrated from C++ to C#. I am reading through about C++ template class and C# generics' differences,
http://msdn.microsoft.com/en-us/library/c6cyy67b(VS.80).aspx
3 questions,
1.
"At the implementation level, the primary difference is that C# generic type substitutions are performed at runtime and generic type information is thereby preserved for instantiated objects."
"preserved for instantiated objects" means?
2.
"In C#, a generic type parameter cannot itself be a generic, although constructed types can be used as generics. C++ does allow template parameters."
"constructed types" means?
3.
What means "C# disallows this; the only language constructs allowed are those that can be deduced from the constraints."?
thanks in advance,
George
|
|
|
|
|
1) When you use a generic type and instantiate an object of a certain type, that type is JIT compiled. Say a generic string list... the list is JIT'ed and now the String list type exists, so if you instantiate a new instance of a generic string list, it does not have to be JIT'ed again, that information already exist.
2) Constructed types are those that have been JIT'ed.
3) Generic types can be constrained with the where clause so that the only types allowed are those that satisfy the constraints.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|