|
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
|
|
|
|
|
Quite honestly, if I had the time I would not use IE at all. Better use a recompiled Mozilla or other programmable browsers with source code.
And put web page filtering on top of it.
What has stopped me many times already with programming IE is that there are many cases where the IE API doesn't work as expected. For instance, when you have frames in the web page, several events are not triggered at all, or you have to subscribe special things. None of this is documented. So it takes time, and there is no guarantee at all you succeed.
Besides that, IE uses multiple threads. One thread for each picture being downloaded for instance, which means it is hard to stop the process as a whole.
If you go start programming IE, then you may consider this scenario :
- I assume you've got the target URL
- use MSHTML as a COM object to download the html code from that URL. (you also could use the wininet library). Store it as a file. To do this, look for the MSDN sample called "Walkall" (C++ code).
- filter the html code
- add the <base href="URL"> tag inside the HTML code, in order to mimic the right base domain.
- ask IE to load this html code in the browser : document.load(...)
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.
|
|
|
|
|
Can anyone help...
Can anyone point me to a site with free .Net components specifically an Outlook bar.
Newby question: How can I align controls on the form. I want a panel to be aligned left on the form, but the Align menu options never become enabled.
TIA
|
|
|
|
|
Jinwah wrote:
Can anyone point me to a site with free .Net components specifically an Outlook bar.
Sure, right here: C# OutlookBar[^]
Nick Parker
The goal of Computer Science is to build something that will last at least until we've finished building it. - Unknown
|
|
|
|
|
Jinwah wrote:
How can I align controls on the form. I want a panel to be aligned left on the form, but the Align menu options never become enabled.
Aligning aligns two or more controls to each other, not to the form. Thus if you select two or more controls, you'll get your align buttons. What you really want is Docking... check out the Dock property for your control.
Paul
|
|
|
|
|
Hi,
I'm thinking of capturing some regions of my screen
into a Bitmap object. Does anyone have any ideas?
Thanks
Li-kai Liu
|
|
|
|
|
Hi
Eric Gunnerson has a library available on GotDotNet.com[^]. The zip is called Win32window.zip, was a bit tricky to find. You can email me if you cant find it. Unfortunately its a bit long too paste
Cheers
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
try this...
public Bitmap CaptureWindow(string windowTitle)<br />
{<br />
RECT rect = new RECT();<br />
IntPtr windowDC;<br />
IntPtr dc1;<br />
IntPtr hWnd;<br />
<br />
if (windowTitle == null)<br />
{<br />
hWnd = FindWindow(null, "DISPLAY");<br />
windowDC = GetWindowDC(hWnd);<br />
rect.right = Screen.PrimaryScreen.Bounds.Width;<br />
rect.bottom = Screen.PrimaryScreen.Bounds.Height;<br />
}<br />
else<br />
{<br />
hWnd = FindWindow(null, windowTitle);<br />
windowDC = GetWindowDC(hWnd);<br />
int returnCode = GetWindowRgnBox(hWnd, ref rect);<br />
}<br />
<br />
Graphics g1 = Graphics.FromHdc(windowDC);<br />
Bitmap MyImage = new Bitmap(rect.right, rect.bottom, g1);<br />
Graphics g2 = Graphics.FromImage(MyImage);<br />
<br />
dc1 = g1.GetHdc();<br />
IntPtr dc2 = g2.GetHdc();<br />
<br />
BitBlt(dc2, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, dc1, 0, 0, 13369376);<br />
<br />
g1.ReleaseHdc(dc1);<br />
g2.ReleaseHdc(dc2);<br />
<br />
ReleaseDC(hWnd, windowDC);<br />
<br />
return MyImage;<br />
}<br />
<br />
[DllImportAttribute("gdi32.dll")]<br />
private static extern bool BitBlt(<br />
IntPtr hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc,
int nXSrc,
int nYSrc,
System.Int32 dwRop
);<br />
<br />
[DllImportAttribute("gdi32.dll")]<br />
private static extern IntPtr CreateDC(<br />
string lpszDriver,
string lpszDevice,
string lpszOutput,
IntPtr lpInitData
);<br />
<br />
[DllImportAttribute("User32.dll")]<br />
private static extern IntPtr FindWindow(<br />
string lpClassName,
string lpWindowName
);<br />
<br />
[DllImportAttribute("User32.dll")]<br />
private static extern IntPtr GetWindowDC(<br />
IntPtr hWnd
);<br />
<br />
[DllImportAttribute("User32.dll")]<br />
private static extern IntPtr ReleaseDC(<br />
IntPtr hWnd,
IntPtr hdc
);<br />
<br />
[StructLayout(LayoutKind.Sequential)]<br />
struct RECT<br />
{<br />
public Int32 left; <br />
public Int32 top; <br />
public Int32 right; <br />
public Int32 bottom; <br />
}<br />
<br />
[System.Runtime.InteropServices.DllImportAttribute("User32.dll")]<br />
private static extern int GetWindowRgnBox(<br />
IntPtr hWnd,
ref RECT rect
);
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Philip Fitzsimons wrote:
[StructLayout(LayoutKind.Sequential)]
struct RECT
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
}
OK, tell me, why dont you use the Rectangle struct defined in the .NET framework?
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
1. 'cause it did not occur to me.
2. 'cause I just translated the API directly, I was not trying to be clever
good point.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
No, I was just wondering. In my experience Rectangle and the other Drawing structs have been fine for marshalling. I have seen people this alot though...even MS people
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|
are you saying we can re-write this
[System.Runtime.InteropServices.DllImportAttribute("User32.dll")]
private static extern int GetWindowRgnBox(
IntPtr hWnd, // handle to window
ref RECT rect // rectangle
);
to
[System.Runtime.InteropServices.DllImportAttribute("User32.dll")]
private static extern int GetWindowRgnBox(
IntPtr hWnd, // handle to window
ref Rectangle rect // rectangle
);
But wouldn't it be relatively confusing because the last two field actually mean different things (width, height in Rectangle, but right, bottom in RECT)...
|
|
|
|
|
Li-kai Liu (Angus) wrote:
are you saying we can re-write this
No! I was wrong. Thanx for pointing it out. For some strange bizarre reason, my brain recorded wrong info Or maybe I'm thinking of something completely different. I have tried to find it, but it was one of those snippets I wrote for someone, but never saved it. In fact, I found 16 blank WindowsApplictions in my code directory.
CHeers
Give them a chance! Do it for the kittens, dear God, the kittens!
|
|
|
|
|