|
agreed...how are your memoirs coming along?
|
|
|
|
|
I have an AxWebBrowser control displaying a certain page that has two input boxes. I want to Click a button on the form, and have values inserted into those two input boxes. How can I do that?
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
If the button is in the web page, then just use embedded javascript in your page.
If the button is in your Windows Form, get the IHTMLDocument2 reference from AxWebBrowser.Document (the interface is defined in the Microsoft.mshtml.dll assembly which should be in your GAC when you install VS.NET, among other things). From that, you can enumerate the controls or get them by ID or NAME. Then just set their innerText property or something along those lines.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey all, I understand how to pull methods/structs out of the dll for use in my C# app, but how do I pull out some #define values for my use in the C# app? I need to do this, becuase all the unmanaged functions return HRESULT values for error checking and I need to check those values for the actual errors which may occur...help!
Jason
|
|
|
|
|
You can't pull #defines out of a .DLL. They are c compilter directives and don't represent any code or data. They're primarily used to define macro's for the compiler to do an advanced search and replace in your code to simplify code writing.
You'll need to go through the original source files for the .DLL, usually the .h files to find the values and their meaning.
Are you looking for Anything in particular?
RageInTheMachine9532
|
|
|
|
|
Ya, I know that...I'd gladly pull them outa the dll, but here's how they are defined:
#define PEER_E_INVALID_RECORD MAKE_HRESULT(SEVERITY_ERROR, FACILITY_P2P, 0x2010)
That's just an example, but they are all similar to that, I don't have an actual value I could use.
|
|
|
|
|
Bottom line is you can't. Their not in the .DLL!
The PEER_E_INVALID_RECORD identifier is replaced with the actual value when the code in compiled. The method in which the value is stored depends heavily on the context that it's used. Most will end up being an operand in an assembly intruction, so they don't show up in the DATA segment in the file .DLL.
Since you have the source, what you could do is write a C++ console app that #include's that header file and just writes out the resulting values of the #define's:
printf("PEER_E_INVALID_RECORD: %x\n", PEER_E_INVLID_RECORD);
RageInTheMachine9532
|
|
|
|
|
That's what I was afraid of....sorry for the confusing posts :P
Thanks
|
|
|
|
|
Short answer:
You don't. #define's are actually replaced in code before the resulting code is compiled.
Example:
#define MY_NUMBER 1
int myNumber = MY_NUMBER;
is converted to this before compiling:
int myNumber = 1;
Jeremy Kimball
|
|
|
|
|
Doing a command line compile with the /P option will output the preprocessor output to a file, which is another possible option, depending on how your code is structured.
This link has an example of using it.
http://msdn.microsoft.com/msdnmag/issues/04/01/windowsshell/default.aspx
My goal is to look at code like a chessmaster looks at a chessboard to see positions and possibilites beyond lines and characters.
|
|
|
|
|
Does anyone know about an implementation of a strongly typed hash-table so I can only change the types and continue in development?
I need need it because of avoiding the boxing/unboxing overhead.
--------
Dave
|
|
|
|
|
Boxing and unboxing only occurs for value types, so if you're adding reference types as keys and values you don't have to worry. Even if you were to find an extendable Hashtable , it will still use object variables to provide generic storage (just like the CollectionBase uses an internal ArrayList ). .NET 2.0 introduces generics that will solve this problem, though.
I know there's none in the .NET FCL but you could always try google. Perhaps you might even find an implementation of IDictionary (always handy to implement appropriate interfaces, which StringDictionary doesn't for some weird reason) for value types.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
check out codeSmith
it has templates for generating type specific container classes.
My goal is to look at code like a chessmaster looks at a chessboard to see positions and possibilites beyond lines and characters.
|
|
|
|
|
Does anyone know how I can add a link "Send feedback" into the caption bar near the close button? I am about to release a new product and though it would be great to have.
... could be a nice article on this.
|
|
|
|
|
You have to override WndProc in your Form and handle the WM_NCPAINT (0x0085) notification message. You then dynamically get the coordinates of the new button and draw it using ControlPaint.DrawButton .
A quick search turned up the following example: http://www.dotnet247.com/247reference/msgs/41/207281.aspx[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've tried out the example given by Heath and found it to be a pain in the a** to work with. I think this is because in order to draw over the top of the caption bar, you have to call the base class WndProc() first, then draw on top of what it has done. But (always one these!) there are issues with with drawing the overlay when maximizing the window and returning from a minimized state. Try this out:
[DllImport("user32.dll")] public static extern IntPtr GetWindowDC(IntPtr hWnd);<br />
[DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr hWnd);<br />
[DllImport("user32.dll")] public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);<br />
[DllImport("user32.dll")] public static extern bool IsIconic(IntPtr hWnd);<br />
[DllImport("user32.dll")] public static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);<br />
<br />
public const int WM_NCPAINT = 0x0085;<br />
public const int WM_NCACTIVATE = 0x0086;<br />
public const int WM_SIZE = 0x0005;<br />
public const int WM_ACTIVATE = 0x0006;<br />
public const int WM_PAINT = 0x000F;<br />
<br />
private System.Windows.Forms.Button button1;<br />
private bool skipNCPAINT = false;<br />
<br />
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]<br />
protected override void WndProc(ref Message m)<br />
{<br />
switch (m.Msg)<br />
{<br />
case WM_NCPAINT:<br />
{<br />
Debug.WriteLine("Message: WM_NCPAINT ; WPARM: " + m.WParam.ToInt32().ToString("X") + "; LPARM: " + m.LParam.ToInt32().ToString("X"));<br />
if( skipNCPAINT )<br />
{<br />
Debug.WriteLine("Told to skip WM_NCPAINT!");<br />
skipNCPAINT = false;<br />
base.WndProc(ref m);<br />
InvalidateRect( m.HWnd, IntPtr.Zero, true );<br />
break;<br />
}<br />
else<br />
{<br />
base.WndProc(ref m);<br />
PaintNC(m.HWnd);<br />
m.Result = IntPtr.Zero;<br />
break;<br />
}<br />
}<br />
<br />
case WM_NCACTIVATE:<br />
{<br />
Debug.WriteLine("Message: WM_NCACTIVATE ; WPARM: " + m.WParam.ToInt32().ToString("X") + "; LPARM: " + m.LParam.ToInt32().ToString("X"));<br />
base.WndProc(ref m);<br />
PaintNC(m.HWnd);<br />
m.Result = IntPtr.Zero;<br />
if( m.WParam.ToInt32() == 1 )<br />
skipNCPAINT = true;<br />
break;<br />
}<br />
<br />
case WM_SIZE:<br />
{<br />
Debug.WriteLine("Message: WM_SIZE ; WPARM: " + m.WParam.ToInt32().ToString("X") + "; LPARM: " + m.LParam.ToInt32().ToString("X"));<br />
base.WndProc(ref m);<br />
PaintNC(m.HWnd);<br />
m.Result = IntPtr.Zero;<br />
break;<br />
}<br />
<br />
default:<br />
base.WndProc(ref m);<br />
break;<br />
}<br />
}<br />
<br />
protected void PaintNC(System.IntPtr hWnd)<br />
{<br />
if( !IsIconic( hWnd ) )<br />
{ <br />
int ourButtonWidth = 60;<br />
IntPtr hDC = GetWindowDC(hWnd);<br />
Graphics g = Graphics.FromHdc(hDC);<br />
<br />
int CaptionHeight = Bounds.Height - ClientRectangle.Height;
<br />
Size CloseButtonSize = SystemInformation.CaptionButtonSize;<br />
<br />
int X = Bounds.Width / 2 - (ourButtonWidth / 2);<br />
int Y = 6;<br />
Debug.WriteLine("Size: " + X.ToString());<br />
ControlPaint.DrawButton(g, X, Y, ourButtonWidth, CaptionHeight - 12, ButtonState.Normal);<br />
<br />
g.Dispose();<br />
ReleaseDC(hWnd, hDC);<br />
}<br />
}<br />
<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
Debug.WriteLine("----------------------------------------------------------------------");<br />
}<br />
<br />
}
RageInTheMachine9532
|
|
|
|
|
If i have an Xml-document like this:
<?xml version="1.0" standalone="yes"?>
<sessions version="1.0">
<session name="Development">
<parameters>
<developmentsession>true</developmentsession>
<rootdirectory>n:\realsoftware</rootdirectory>
<validoslist>win32</validoslist>
<propathunix />
<propathwin32>.,[rootdirectory]\usr\%username%,[rootdirectory]\fastforward\pvs100,[rootdirectory]\fastforward\pvs100\obj,[rootdirectory]\fastforward\pvs100\src,[rootdirectory]
</propathwin32>
</parameters>
</session>
<session name="AppserverDevelopment">
<parameters>
<developmentsession>true</developmentsession>
<rootdirectory>f:\pro.net\realsoftware</rootdirectory>
<validoslist>unix,win32</validoslist>
<propathunix>.,[rootdirectory]/usr/%username%,[rootdirectory],[rootdirectory]/start/general,[rootdirectory]/fastforward/ffw100/obj,[rootdirectory]/fastforward/ffw100/src
</propathunix>
<propathwin32/>
</parameters>
</session>
</sessions>
Now i want what is in propathunix in a listbox, but in the listbox [rootdirectory] must be changed in the actual directory.
Something like this
.
f:\pro.net\realsoftware/usr/%username%
f:\pro.net\realsoftware
f:\pro.net\realsoftware/start/general
f:\pro.net\realsoftware/fastforward/ffw100/obj
f:\pro.net\realsoftware/fastforward/ffw100/src
Anybody an idea how to get it like that?
Thx a lot in advance
|
|
|
|
|
When binding the split elements to the ListBox (or just simply creating list items), why not just use String.Replace on each path like so:
string[] paths = propathunix.Split(",");
string root = rootdirectory;
foreach (string path in paths)
{
path = path.Replace("[rootdirectory]", root);
listBox1.Items.Add(path);
} Or are you asking how you could display the string like that, but not actually change the string? If so, consider handling the ListBox.DrawItem event and set ListBox.DrawMode to DrawMode.OwnerDrawFixed or DrawMode.OwnerDrawVariable . You could replace the string that gets drawn and then draw the string yourself.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm using the Process.GetProcesses(computerName) method to get processes running at remotes computers. That method works fine while getting processes running on remote computers running on Windows NT/2000/XP, since I have administrative privileges on such computers.
But I'm getting a System.InvalidOperationException (Couldn't get process information from remote machine) while trying to get the processes running at a Windows 98 remote computer, where I have privilege to log on in. I'm also sure this Windows 98 computer is working fine on the network.
I'm using Visual Studio 2002 on Windows XP Pro.
Does anybody know what is the problem?
Thanks.
Nilson
|
|
|
|
|
I'm surprised you didn't get the PlatformNotSupportedException mentioned in the documentation since Win98 doesn't support this operation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in system.windows.forms.dll<br />
<br />
Additional information: Unable to get the window handle for the 'AxWebBrowser' control. Windowless ActiveX controls are not supported.
This happens whenever the application terminates.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
The only instance I can find of something like this has a bit of a weird solution.
Try putting the WebBrowser control in a Panel control.
RageInTheMachine9532
|
|
|
|
|
In your container, override Dispose(bool) (if it isn't already, which VS.NET does automatically when you create a new class from the appropriate templates) and be sure to call AxWebBrowser.Dispose . This typically helps.
The problem is basically a race condition. The window gets destroyed (hence, no window handle) before the control itself is cleaned-up.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am getting a runtime exception when i register a remote client for receving events from the server.
I have 3 main components in my solution
an interface to be shared between client and server
using System;
namespace ItfDelegate
{
public delegate void RemoteCall(string p);
public interface IDelegateHandler
{
void HandleRemote(string p);
event RemoteCall GetStock;
}
}
The server (registered as single call)
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using ItfDelegate;
namespace cbConsoleServer
{
class ClsServer:MarshalByRefObject,IDelegateHandler
{
public event RemoteCall GetStock;
public void HandleRemote(string p)
{
GetStock(p);
}
[STAThread]
static void Main(string[] args)
{
......standard single call registration code
}
}
}
And the remote client that registers for callbacks
using ItfDelegate;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
namespace RemoteDelegateClient
{
[Serializable]
class ClsClientHandler
{
string strinit;
public void Getmystats(string s)
{
strinit=s;
}
[STAThread]
static void Main(string[] args)
{
..gettting server proxy through activator.getobject
ClsClientHandler cs = new ClsClientHandler();
IDelegateHandler svr=(IDelegateHandler)o;
svr.GetStock += new RemoteCall(cs.Getmystats);
svr.HandleRemote(cs.ToString());
Console.WriteLine(cs.strinit);
}
}
}
I get an exception while registering the client with the event.What do i need to do?THe stack trace is as follows
Unhandled Exception:
System.Runtime.Serialization.SerializationException: Parse
Error, no assembly associated with Xml key a2:http://schemas.microsoft.com/clr/n
sassem/RemoteDelegateClient/RemoteDelegateClient%2C%20Version%3D1.0.1545.32282%2
C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull ClsClientHandler
Server stack trace:
at System.Runtime.Serialization.Formatters.Soap.SoapHandler.ProcessGetType(St
ring value, String xmlKey, String& assemblyString)
at System.Runtime.Serialization.Formatters.Soap.SoapHandler.ProcessType(Parse
Record pr, ParseRecord objectPr)
at System.Runtime.Serialization.Formatters.Soap.SoapHandler.ProcessAttributes
(ParseRecord pr, ParseRecord objectPr)
at System.Runtime.Serialization.Formatters.Soap.SoapHandler.StartChildren()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(Head
erHandler handler, ISerParser serParser)
at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Str
eam serializationStream, HeaderHandler handler)
at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IS
erverChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestH
eaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& response
Headers, Stream& responseStream)
Exception rethrown at [0]:
|
|
|
|
|
The exception states that the assembly to which the callback points cannot be found, which means that the server doesn't know how to deserialize that type since it doesn't exist in a resolvable path on the server (i.e., in the same directory as the remoting server, in the GAC, or in a number of other places that the .config file can also specify). You need to provide that client assembly to the server. Typically, though, just use a shared assembly with an interface that would have the callback method, which should do the trick since the server shouldn't care about the implementation so long as you pass the interface's implementation of the callback method declared using the interface itself.
Also, if the remoting object is registered as single call, the may not work depending on how you call it. The remoting object would be instantiated only for that single method call, so unless you invoke the callback within that call it won't work because the object would be disposed after completing the method call.
Microsoft MVP, Visual C#
My Articles
|
|
|
|