|
Hey everyone, first time poster here.
I'm working on a C# project where I need an image and things drawn on top of the image to automatically scale to the size of the form when the user does the following options: manual resize, maximize, restore from maximize.
The user can also use a zoom tool, and when this happens scroll bars for panning the image appear and the actual size of the form is not changed.
I've got some event handlers attached to the form's Resize and ResizeEnd events to control the automatic scaling, but I've run into a few problems:
1. ResizeEnd gets called when I drag and drop the form, meaning the image and objects on it are automatically scaled, so if the user has used the zoom tool to zoom in, this gets overridden by the resize.
2. I need to make it so that automatic resizing is not done on a minimize or a restore from a minimize, for the same reason as #1 -- a manually zoomed image should stay manually zoomed.
I tried to override WndProc to filter out certain ones, but to no avail.
Any help or guidance would be appreciated, thanks!
|
|
|
|
|
PhilDanger wrote: I've got some event handlers attached to the form's Resize and ResizeEnd events to control the automatic scaling, but I've run into a few problems:
1. ResizeEnd gets called when I drag and drop the form, meaning the image and objects on it are automatically scaled, so if the user has used the zoom tool to zoom in, this gets overridden by the resize.
2. I need to make it so that automatic resizing is not done on a minimize or a restore from a minimize, for the same reason as #1 -- a manually zoomed image should stay manually zoomed.
I tried to override WndProc to filter out certain ones, but to no avail.
If I understand the problem, you don't have to do this. All you need to do is check the status of the form's WindowState property. If it's Normal or Maximized, do your scaling as normal. Otherwise, skip the scaling.
|
|
|
|
|
Hi Dave,
Could you clarify this a bit more for me, are you suggesting that I check the WindowState in the Resize(End) handlers?
If this is in fact the idea, I still am left with a few problems -- the form drag still calls the ResizeEnd event, which will force an automatic resize even which the state check in there since the Form will be Normal, and when I restore from a minimize, the Resize event is fired AFTER the form restores itself, so although it won't resize when it minimizes, it will resize when it is restored).
Thanks for the start.
|
|
|
|
|
Hi,
the way I see it you have three input variables: size, zoom and pan.
They are state variables in your sizing/zooming/panning problem.
whenever one of them changes, you must recalculate and adapt things.
So I would suggest you create one method that takes size, zoom and pan as input parameters
and does whatever needs to be done; now all your handlers related to changing either
size, zoom or pan should call that one function.
You probably are not keeping size information in your own variables; that's OK.
But that probably it is also what confuses you, since no one is holding your zoom/pan
information for you, and its my guess that is at the heart of your problem.
Anyway, I concur with Dave; there is no need to fiddle with WndProc here.
Hope this helps.
|
|
|
|
|
Hi Luc,
Thanks for the suggestions, I'll look into it.
In the mean time, I implemented a hasty fix that of course has it's own drawbacks. The image was actually residing in a PictureBox that was inside a Panel, and the panel controlled scrolling when the PictureBox got too big to fit... instead of using the Form's Resize event, I instead hooked up a handler to the panel's Resize. This work fine except for the fact that the panel fired off a Resize when scroll bars were added. The fix to this was just to put everything in ANOTHER panel and use that one's Resize event to handle automatic resizing.
The drawback of this however, is that a Panel doesn't have ResizeBegin or ResizeEnd events -- I was scaling the image every half a second it was being resized so that it wasn't doing an expensive resize 20 times a second and then doing one final resize on the ResizeEnd. With the new "fix", I can stop resizing between the times when it is making the new scaled image, and it won't fit properly (just a bit off).
Now to investigate this one!
Thanks again,
Phil
|
|
|
|
|
Hi Phil,
the ResizeBegin/End events are new to me; I did most of my work in 1.1 compatible way.
And I avoid using PictureBoxes, they are not worth the trouble in my opinion.
When a panel suddenly shows/hides one or both scrollbars, naturally that affects the
remaining "clientsize". For that reason, I do what you ar doing now, I think, that is
having a non-scrolling (but moving) panel inside a scrolling panel.
You probably can give your panel a ResizeBegin/End functionality by hooking them to
the form; so you could disable your panel resize logic while the form is between
ResizeBegin and End (unless you want ways to resize the panel without resizing the form...).
BTW, I read in the doc that ResizeBegin/End also fires when you MOVE the form.
Cheers.
|
|
|
|
|
i used key work execute for run stored procedure but i need retrieve result as table
i used this command (Exec sp_help_jobhistory @job_name ='KEETOS\KEETOS-NorthWnd_rpl' , @mode ='Full')
i need retrieve result into table
123
|
|
|
|
|
You waited a full 2 minutes to post this again?
if the sp returns a table, you have a table. What is the problem?
|
|
|
|
|
i used key work execute for run stored procedure but i need retrieve result as table
i used this command (Exec sp_help_jobhistory @job_name ='KEETOS\KEETOS-NorthWnd_rpl' , @mode ='Full')
i need retrieve result into table
123
|
|
|
|
|
I have a dataset with 2 tables in it. I am relating the 2 tables based like a master/detail relationship. The problem I am having is in instances where 2 of the masters are the same an error is returned: 'These columns don't currently have unique values.' I need to figure out how to catch this exception when it is thrown so it can be emailed to be fixed and display a user friendly message stating it is being taken care of. How can I accomplish this? I have looked at the ArgumentException Class but neither of its subs will work. It is within range and not due to a null being passed in.
Any help is greatly appreciated.
~Candi
|
|
|
|
|
Ok I figure out how to do it in a Try/Catch. However I need to send the values that were returned in the first table of the dataset via email to the help desk. How do I get the values out of the dataset if I am not assigning it to an object on a webpage?
~Candi
|
|
|
|
|
get ds.tables[0].rows["column_name"].value and do watever u want.Wat is the problem if it is already in a dataset???
Am i missing something??
I was born dumb!!
Programming made me laugh !!!
--sid--
|
|
|
|
|
Because it is in the dataset, I cannot email the person who fixes the error what is showing up in the query that populates the dataset. She needs to be able to see the error and what is in the dataset so she knows what values need to be fixed.
When I use the ds.tables[0].rows["column_name"].value It causes it to break. I need all of the rows in a particular column (PName) that are in Table[0] in the dataset. How do I loop through to display all of the rows' values?
~Candi
|
|
|
|
|
i have reached to known using sockets which TCP/IP ports are closed or opened.application which is using/listening the particular port, but how i can know which is the application whick is using/listening the particular port?
|
|
|
|
|
Hi,
I am writing context menus for windows explorer int C# to integrate my application.
I created the menu, But I am facing problem at Attaching an image/icon/bitmap to the menu(like winzip).
Please give me some help so that I can complete.
Thanks
Ramesh
|
|
|
|
|
Just so we're all on the same page here,
Are you asking how you add an icon to a menu WITHIN your application ?
or
Are you asking how you add a menu item with an icon to the windows shell (i.e. Something that appears when a user right clicks a file in explorer for example)?
[Link]
Is a very simple example of this - just search in google (or even here) for "Windows Shell menu c#" or terms like that
Mark
|
|
|
|
|
Hi Mark
Thank you, I got it.
Ramesh
|
|
|
|
|
Hi,
Right let me briefly explain what I am trying to achieve and perhaps someone might be able to point me to the best method to achieve it.
I am creating an updater that will run update sql on clients systems, by using sql embedded into an XML file. This updater needs to be version independent of our client platfroms. The updater is just updating a library that the system references.
My problem is that if I apply an update that uses a newer database schema against an older version, it will cause the update to fail. How would we go about creating objects that perhaps are dynamically built according to the schema of the database and being able to ignore any new columns that have been added.
What I want to achieve is an updater that will update a library in the database, regardless of what version of the system it is using and if that a new update is being applied to an old version it will be able to handle itself and apply only the data that is needed according to the schema.
Sorry this is a little hard to explain, hopefully that makes some sense.
We have looked at an object approach or perhaps doing it all via XML and are not sure which is the best or if we choose object method how do we go about it.
Regards
Paul
|
|
|
|
|
Hmmmm,
Interesting issue. I know we have had similiar issues in the past =
Can I ask how the clients get the update file in the first place ? Is it from some Web Service or do they just download it etc?
I'm also presuming that the Actual application itself which opens this XML file will know that it is possible that it will run SQL on potentially multiple different databases (i.e. ones with different schemas and potentially different versions).
If that is the case then why not actaully send down a ZIP file or Cabinet file with several XML files. One primary XML file with essentially a manifest set of nodes - each one referencing one of the other XML files in the zip/cab, seperated by Version/Schema.
For example the primary XML file might look something like this...
<manifest>
<file version="SQL2000" schema="XXXX" filename="Xmlfile1.xml" />
<file version="SQL2000" schema="YYYY" filename="Xmlfile2.xml" />
<file version="SQL2000" schema="ZZZZ" filename="Xmlfile3.xml" />
<file version="SQL2005" schema="XXXX" filename="Xmlfile4.xml" />
</manifest>
It would then be up to the app itself to work out which version of client database and which schema (or whatever criteria you need) and then check this against the manifest XML file and then load in the relevant SQL xml file and then run the SQL contained within it.
Whilst it may seem inefficient to ship all the files to every client, once it's zipped or compiled into a cabinet file the actual file will be pretty small and you also enjoy the benefit of keeping the update logic seperate for each schema/database type.
Mark
|
|
|
|
|
Hi Mark,
many thanks for response in regards to my question. The way the system will work is that we send an update to the client, they are than able to upload this xml file using the application, the application then applies the updates contaied within the file.
We really want to be able to move away from shipping files with multiple versions, as we want the updater to be completly version independent.
The reason we have chosen XML initially is that we can compare old xml to new xml file to genreate the necessary insert, updates and deletes. Plus if there are new columns it just means tewaking the sql that outputs the xml. Where as to do it by an object model, any methods/fucntions have to be all updated to cope with new columns/tables and any calls to those methods/functions must be updated. This would be laborious, unless there was a method to do it dynamically. The reason we are looking at an object model is that all our programming in the system uses this and we would like to replicate that for ease of use, but I do understand that XML is the most appropriate method.
Thanks again
Paul
|
|
|
|
|
Hello,
I need to find a way to manipulate the displaying of the "From" email address. Since I am also using the Sender field to send the email message on behalf of the Sender. So the the person who receives the message will see some thing like this from the email header (I am using the .Net CDO Mail API):
From: jblow@abc.com on behalf of jdoe@xyz.com
To: john@hotmail.com
Here is the sample code that I have used:
cdo = Server.CreateObject("CDO.Message");
cdo.From = "jdoe@xyz.com";
cdo.ReplyTo = "jdoe@xyz.com";
cdo.To = "john@hotmail.com";
cdo.Sender = "jblow@abc.com";
...
What I really want to do here is that I just want to manipulate the displaying of the From email address header so it will just display as:
From: jdoe@xyz.com
Thanks for any respond.
John
|
|
|
|
|
|
Hi Muhammad,
Can you please give me a little bit more detail?
Thanks,
John
|
|
|
|
|
I am using AllocConsole to add a console window to a window form at runtime but i can't write to it using console.write.
|
|
|
|
|
CiNN wrote: I am using AllocConsole to add a console window to a window form at runtime
Why?
|
|
|
|