|
That's it
|
|
|
|
|
Hello everybody,
I have a strange problem with DrawString in my OnPrintPage event handler I need to print a few lines of text (field names) that is right-aligned. I'm using StringFormat to set the text alignemt and a RectangleF instance to set the coordinates. This is the code snippet:
StringFormat formatRight=new StringFormat();<br />
formatRight.Alignment=StringAlignment.Far;<br />
....<br />
RectangleF rectRight=new RectangleF(m_nMarginLeft+80,m_nMarginFields, 50, 30);<br />
e.Graphics.DrawString("Field name 1:", m_fontField, Brushes.Black, rectRight, formatRight);<br />
e.Graphics.DrawString("Field 1 value ...", m_fontGeneric, Brushes.Black, rectRight.Right, (float)(rectRight.Top-0.5));<br />
<br />
rectRight.Offset(0,m_fontGeneric.GetHeight(e.Graphics));<br />
e.Graphics.DrawString("Looong field name 2:", m_fontField, Brushes.Black, rectRight, formatRight);<br />
e.Graphics.DrawString("Field 2 value ...", m_fontGeneric, Brushes.Black, rectRight.Right, (float)(rectRight.Top-0.5));<br />
...
(Page units are milimeters) The problem is, that the fields are actually not exactly right aligned. The longer the text is, the more it is offset to the left (i.e. when printing it makes some 2 milimeters difference for field names which are twice/half the size of each other). The same thing happens when I use one multi-line string in a rectangle of larger height. I have absolutely no clue of what can be wrong? Therefore any clues are highly appreciated Am I doing something stupid or what? Thanks for any help.
Have a nice day,
Rado
|
|
|
|
|
Hi,
I can use Directory.GetLogicalDrives() method to get the drives attached to the computer but it only returns an array of strings which contain the drive letters (i.e. A:\, C:\, D:\, etc). What I want to know is how can I get the volume names and is there a way to find out the type of drive (floppy, hard drive, CD-ROM, networked) within the .NET framework. I noticed in the SDK documentation that there appears to be a VB.NET function that will get the volume names, but there doesn't appear to be one for C#.
Thanks
WJ
|
|
|
|
|
Wjousts wrote:
I noticed in the SDK documentation that there appears to be a VB.NET function that will get the volume names, but there doesn't appear to be one for C#.
MSDN is full of errors. If it is .NET any language can be used BTW what is the "VB.NET function" called?
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
I think it was the dir() function described here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctdir.asp
At least I think that was the one I was looking at earlier, it so bloody hard to find anything in MSDN and even harder to find it again. Anyway, it appears to be a function that is specific to VB and not part of the .NET framework itself. I couldn't find the same function anywhere within the .NET class library. What gives?
|
|
|
|
|
I guess you will have to use WMI then... Have a look at the System.Management namespace.
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Okay, I think I have it figured out using WMI inspite of the documentation. Could they make it any sketcher?
|
|
|
|
|
Wjousts wrote:
Could they make it any sketcher?
Dont give them ideas!
Paul
|
|
|
|
|
I think you can only use win32 API for this:
GetVolumeInformation
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hello,
I know the tree control is one of the build-in components inside the toolbox of VC.NET C# window form, but it seems missing in web form control toolbox. The main purpose for this is that I got a database organized like tree and require to show it in ASPX. The DataGrid control cannot fit in my requirement.
Any suggestion?
Thanks.
-mh
|
|
|
|
|
|
Does anyone know how to do:-
1. Display a single & double precision floating point value.
a) the internal representation in hexadecimal
b) the true exponent in decimal, hexadecimal and binary
c) the significand in binary
d) the associated name
|
|
|
|
|
Is this homework?
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
In VC++ i've always used the emessage WM_INITDIALOG.
In C# and dialog inherited from System.Windows.Forms.Form is this message
not attended.
I tried to do it in this way:
protected override void WndProc(ref System.Windows.Forms.Message m)<br />
{<br />
<br />
switch(m.Msg)<br />
{<br />
case WM_INITDIALOG:<br />
break;<br />
default:<br />
break;<br />
}<br />
base.WndProc( ref m);<br />
}
but it dosen't work . I mean, that with little help of my friends, i should
do it !!!
Best regards
|
|
|
|
|
Hi
Marcin wrote:
case WM_INITDIALOG:
You will need to define the constant somewhere, or if you are doing alot of WM related stuff, dump them all in an enumerration.
const int WM_INITDIALOG = 0x0110;
Cheers
[edit]
I read your message again, so all of the above mite be useless. Can you please give more info? What is the problem your experiencing? Does it just do nothing?
[/edit]
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
Im affter defined
<br />
private const int WM_INITDIALOG = 0x0110;<br />
thanks
|
|
|
|
|
I'm trying to create something similar to the start page for my application.
I'd ideally like to have a table with small icons that I can trap the
OnClick event. The contents of the table are dynamic.
One option is to make a webcontrol of sorts that I fill with HTML. Problem
is how to trap those events. Prefer to do it without IE (just another control to check for on the install).
I would like to stay away from the WinForm grid control and have something
more along the lines that looks similar to the VS.NET start page or the
Groove Welcome page
(http://www.groove.net/products/popup/workspace/welcome.html).
Any ideas?
Andrew Connell, MCDBA
IM on MSN
andrew@aconnell.com
|
|
|
|
|
It is easy
Once your web page is designed (just steal the Start page code from VS.NET, right click / View source. Jeecool!), just add onclick events, and add window.external.myMethod calls.
Now in your app hosting the web browser, you have a IDispatch interface exposing myMethod(), and this will get automatically called.
I have to admit that you'll get more easily done with full C++ code, because of the IDocHostUIHandler/IDispatch declaration and implementation.
For code sample, download the Driller sample from MSDN.
Be warned that both the VS.NET Start page, and other html pages using window.external, and HTA applications require ActiveX scripting be enabled on the user's browser settings.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
I took a look at the Driller, but it didn't help me as much as I had hoped. Lemme give it a shot...
StephaneRodriguez wrote:
add window.external.myMethod calls
So.... the onclick event is easy... is the syntax just: <img src="sample.gif" onclick="window.external.Button1Clicked('param1','param2')" />
StephaneRodriguez wrote:
Now in your app hosting the web browser, you have a IDispatch interface exposing myMethod(), and this will get automatically called.
So... that code would look something like (in C#)...
public void Button1Clicked(string p1, string p2) : IDispatch<br />
{<br />
MessageBox.Show("Dynomite!");<br />
}<br />
Sorry... this is greek to me... thanks for your first post
Andrew Connell, MCDBA
IM on MSN
andrew@aconnell.com
|
|
|
|
|
Drill has the plumbering you need, but it does it using C++. You obviously need it using C#.
Let's see the key code, in the driller app, the class which implements and subscribes for the custom (window.)external handler is attached like this :
CCustomOccManager *pMgr = new CCustomOccManager;
m_pDispOM = new CImpIDispatch;
AfxEnableControlContainer(pMgr);
So you need your hosting app implement a control site. Searching the .NET framework for the equivalent stuff, I found this[^] :
[C#]
protected virtual ISite CreateSite(
IComponent component,
string name
);
The above method must be implemented by your code, and it will be called by the framework when the app is started.
The implementation of this method must do what the C++ code does, ie provide implementation for the IDocHostUIHandler. In this implementation, that's GetExternal which attaches the site to a class of yours. This class implements IDispatch and implements any number of methods, among which myMethod : the one that gets called with the javascript code.
I know that's hard using C++ already, but trying to do it using C# is just harder. That's questionable.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
StephaneRodriguez wrote:
I know that's hard using C++ already, but trying to do it using C# is just harder.
Thanks... looks like I need to keep looking because C++ is greek to me. You got me going in the right direction.
Andrew Connell, MCDBA
IM on MSN
andrew@aconnell.com
|
|
|
|
|
I got a reply to my similar posting on GotDotNet[^] by an MS guy. He has a work around that seems VERY easy and not too hacky.
What he said he did is to use a 'fake' hyperlink and used the BeforeNavigate2 event to find out what the hyperlink URL is.
I'm going to try this as it seems like a good solution for me. My URL will be a flag like <a href="OpenCollection.1"> and I'll just have a switch statement inside my BeforeNavigate2 event handler method.
-AC
|
|
|
|
|
I need to write a .NET MDI web browser that supports content filtering but I don't quite know where to start. I would like to filter content before it is displayed in the WebBrowser control but I don't know the best practice for doing this.
I want to change the HTML to remove links to sounds, Flash animations, images and whatever else is defined by the user.
It doesn't look as though any of the WebBrowser events will work. Same with the MSHTML DOM events.
Should I be doing this even farther up-stream? Perhaps using a proxy server object and filtering the content there?
- John
|
|
|
|
|
Two options :
- change programmatically IE settings, ( only while your app is running of course), so that animations and/or images are not downloaded or played.
Search codeproject for that. Someone showed how to do this in the past. (it is not a matter of hacking down the registry, because it would require the user relaunches the browser).
- you can host the web browser control, and subscribe for navigationcomplete events or the like. Doing so, you can access the HTML tree with the DOM API. You've got a starting point here[^]. And you've got hooking techniques here[^] and here[^].
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
|
|
|
|
|
Thanks a lot Stephane. The two articles you posted will do the trick I think. I don't like the first because I believe it's inappropriate to globally modify IE settings. What if my app crashes and the changes don't get "undone."
I wasn't aware of the NavigateComplete2 bug in .NET but that would definitely explain why my modifications were not being reflected in the HTML in the browser.
If you were to write a browser application that would allow users to create customized filtering rules, would you utilize the hooking techniques in your articles or is there a different approach?
- John
|
|
|
|
|