|
It sounds like you have a windowing issue. In essence you have a window (the group box), in which you can draw whatever you want. Then, you set another window on top of that one, showing the picture. So, whatever you drew in the group box window will only be visible where the picture box windows do not cover it.
So, how do you fix it? Generally, problems like this are solved with a custom control. Instead of a group box and some picture boxes, you want a control that draws the images directly to the surface of the main window (maybe the group box). That way, your rectangle can be drawn after the image was drawn, letting you see the complete rectangle.
Before you write your own control though, check to see if there already is one that can do the job you require. (There may be a control that looks and acts differently, but accomplishes the goals of your project.)
John
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Posted in the forums for the benefit of others who may have similar questions.
Hello,
I took a look at the running program, and the code you sent to me (with Anakrino). Now that I see what is really going on, I can present the options you have.
Problem: You have conflicting goals here. First, you want to be able to draw a rectangle on the surface of the parent window which will appear above the carpet images in this window. Second, you have separate windows (controls) appearing on a layer above the parent window, making it impossible to draw above the carpets from the parent layer.
Solution: Change your existing specialized control in the following ways:
1) Do not use separate window controls to display the carpets. Instead, use a new carpet class that contains the needed position and image information, but does no other real work.
2) Handle the Paint behavior of your control, drawing the images in the correct locations and scale. This is the major difference. Since you are drawing the carpets directly to the control's surface, you have complete control of whatever may appear above them.
3) Now come the annoying little bits. You'll need to handle the mousedown, mouseup, and mousemove behavior is a little more elaborate fashion than you are currently. When not in zoom mode, check to see whether the user clicked in a carpet, and then wait to see if they move the mouse before the next mouse-up. If they do, then start a drag operation -- dragging whatever object you like.
4) Have a good look at the several specialized C# controls here on CodeProject. Some of the grid or list controls do several of these things, and can teach you how to handle these tasks well.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hi John,
Yesterday I send a few mails with Stewart. In general, he told me to do the same thing. It's all a matter of drawing things in the right order. I use pictureboxes and groupboxes as my controls. Instead I have to right my own and implement paint() methods... Keep track of the different positions and the order I have to draw things... So that is what I'm going to do. I'll look up some _custom controls_ here on codeproject in the hope they will give me some help with that.
So actually the thing I did was bad programming, because I use the common controls that are provided by .NET which do far to much for the things I need. (Due to that I use to much CPU cycles and resources...) I'm glad that I know now that the thing I wanted to do is (as good as) impossible the way I used my different classes.
This is how I interprete your and Stewart's advice... Correct?
So back to work now for the next hmmm 14 hours? =) Thanks again!!
GreetZz,
TweeZz.
// modified
ps: I got an email from Bob Powell with an url... Nice description of my problem... http://www.bobpowell.net/manipulate_graphics.htm
Thank you Mr. Powell!
|
|
|
|
|
PLz tell me tha thow to get the list of all available fonts in system?
Thanx
sorry for my bad English.
|
|
|
|
|
|
Hi,
I looking for a sample where a listview is using.
In the sample I would like :
- add icon,
- add progressbar,
- add combobox,
- add highlight row,
- add sort column,
- add blinking row,
- change colour of row, column or subitem,
- using context menu for each row,
- find idex of an subitem,
- select different views : details, large,list,...
- add tooltip for each row or subitem,
-...
youssef
|
|
|
|
|
You're not looking hard enough, then. Try searching CodeProject or use google. There's plenty of examples out there, though not with everything in that list. My recommendation is to use a third-party library like those from http://www.devexpress.com/[^] or http://www.infragistics.com[^]. Adding all that is a lot more work than you probably think.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Thanks,
But I see this link.
I tested and some properties doesn't exist from my request.
If you know a link where I can find more samples it is great even if I must to buy.
Best regards
youssef
|
|
|
|
|
Look, you're not going to find such a complex control for free! Either buy one, or read the Platform SDK and .NET Framework SDK about Windows Common Controls, Windows messages, Windows Forms, and either make your own or enhance the existing ListView or controls like the one I gave you a link for. It's not a simple project to throw something like this together and if you're just ripping off other people's source you'll never learn anything. There's plenty of examples out there to give you a good start. Learning what it all means and how to add to it is up to you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hey
When i select somthing from the listView the selected item becomes gray. Is there any funktion that could change the color of the selcted item, maby transparent?
Or do i have to override selected in the listView?
//Jimmy
|
|
|
|
|
If ListView.HideSelection is set to false (default), the gray background is not drawn when an item is selected and the ListView does not have the focus.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Okay but it needs to be focus becourse this item i select will display info about it self in a label.
When i moves the mouse pointer over the items, the label folows the mouse and display the item. but if i click on an item then the label will dispare, and the selected item will be gray.
I whant to change so the selected color is not gray, i most have the slect mothod becourse i have a drag and drop on this items.
I want also that the label will be shown even when i click on an item.
//Jimmy
|
|
|
|
|
So set the focus to the ListView using the Focus method. The gray is because the ListView doesn't have focus when you programmatically select an item. The item is still selected even if HideSelection is true , it just doesn't show a background (i.e., it's "transparent"). You really should read the ListView class documentation for these properties and methods, and should for the rest as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can i call a Java code from C# code
|
|
|
|
|
Yes, but not easily. One way is through JNI (Java Native Interfaces), which I discuss in my article Hosting .NET Controls in Java[^] (and older article is posted here on CodeProject but doesn't include Java-calling code like the article above does).
There are also many products out there that generate proxies that allow you to call these directly. There's another article at DevX about some products, Calling Java Classes Directly from .NET[^].
A quick search on google would've turned up these and many others.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
table containing two fields one is code and another is name. i need to fetch repeated names only.(more than one occurance of name and code is not same). any one help to me. thanks in advance.
Have A Nice Day!
Murali.M
Have A Nice Day!
Murali.M
|
|
|
|
|
How about this: SELECT code, name FROM table GROUP BY code, name HAVING COUNT(*) >= 2
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
Ooops, sorry, I didn't notice that you posted this in three different forums and already received a response.
Oh, and SQL questions should, by and large, be submitted in the SQL forum.
What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
|
|
|
|
|
Can C# Control Serial Port?
Which class in .NET Framework is for SerialPort Communicate Programming?
thanks a lot.
|
|
|
|
|
For low level communication you can write to the virtual file "COM1".
|
|
|
|
|
Dear Corinna John
Can you explain for detail how to write to the virtual file "COM1"
in c#?
Thanks a lot!
|
|
|
|
|
Usually you open a file with the name of the serial port (COM[x]). The file doesn't exist in the file system. Whatever you write to the "file" will be sent to the serial port, messages from the device can be read from that virtual file.
FileStream fs = new FileStream("COM1", FileMode.OpenOrCreate);<br />
fs.Write(...);<br />
fs.Flush();<br />
It worked with other languages, I think it should also work with .NET
|
|
|
|
|
Can you do that with (LPT1)?
/\ |_ E X E GG
|
|
|
|
|