|
gekoscan wrote:
Graphics g = Graphics.FromHwnd(this.Handle);
Maybe you can try:
Graphics g = pictureBox1.CreateGraphics();
That gives you the graphics object to paint ON the picture box instaed of the form.
I hope this helps!
Smitha
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant, and she fell on me. Then it wouldn't seem quite so funny.
|
|
|
|
|
How, usually, do you all solve this problem? I'm of course referring to inserts with an apostrophe (single quote) in them.
I have some ideas on how to solve it - either to use a Replace type method or to write a stored procedure (I'm using Access, so it should be one of those Access Query things).
Is there a standard approach which is best?
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
afronaut wrote:
Is there a standard approach which is best?
I will assume you are using C# since you are posting in this forum, however I always typically write a little function to handle this as it can be used throughout an application. Another Access Query really isn't necessary for something like this. Something like the following works well in C#:
string CleanSql(string s)
{
return s.Replace("'", "''");
}
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
We use stored procedures and set up the parameters with, for example "O'Mally", just as they are and it all works swimmingly.
Philip Painter
|
|
|
|
|
Hi,
I am using C# windows forms and I have dragged and and dropped MS web browser control on to the form.
When I navigate to a web page ex:www.hotmail.com and change the focus to another application on the desktop using ALT + TAB and come back to my application again, the web page in the web browser control would have lost focus.
I am using using the following command to navigate
object o=null;
axWebBrowser1.Navigate( textBox1.Text,ref o, ref o, ref o, ref o);
Any idea how to get back the focus
Thanks
Kiran
|
|
|
|
|
Compiled an assembly with visual studio and am now trying to get it to compile on a box with just the sdk and command-line tools.
It's missing the mshtml reference which I think is a com object. Trying to get a type library from the winnt\system32 dll file fails. How would I compile it with just the sdk then?
|
|
|
|
|
First of all, the mshtml.dll file you refer to is not the native dll we are used to with C/C++, but the interop assembly, which is located in <program files>\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll
The way to compile your code is to reference this assembly with the /reference option.
The command line is detailed here[^].
|
|
|
|
|
Hi,
I'd like to programatically display a dropdown menu from a toolbar. To be specific, I'm developing an Explorer bar, and I'd like to give it a menu. As far as I know, the only way to do that is to use a toolbar. So I have a couple buttons (File, Edit), and they both have dropdown Menus. When a user clicks on the File button, I want it to popup the File dropdown menu, just as it might if the user clicked on the dropdown arrow.
I don't see a natural way to do it within the API yet. I tried using Show(), but the only problem is that I'd need to calculate the correct location for the dropdown menu to popup. Any better solutions?
Thanks,
Arun
|
|
|
|
|
hi @ll!
I have the following problem....
I try to access the IE DOM as COM from C# -> no problem for first. Then I try to get a spezific element of the Document in the Internet Explorer (v6). For this I need to recurse through all frames. It works (its only a part of course, all the source would be too much until "X.item(ref newIDoc);" I think (or I'm sure the error is caused because) in the msdn the ".item" is descripted as follows:
"HRESULT item(
VARIANT* pvarIndex,
VARIANT* pvarResult
);"
but I don't know how to do this in C#.
object newIDoc = new object();
newIDoc = I;
mshtml.IHTMLFramesCollection2 X;
X = iDoc.frames;
X.item(ref newIDoc); //-> error
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in xcwrapper.dll
Additional information: Mitglied nicht gefunden.
Anyone any Idea?
thx anyway
mfg Manuel
|
|
|
|
|
frame = X.item(i) is a way to access the ith element of a collection. There is no point in passing the doc instance as param.
|
|
|
|
|
hi!
I see...
that sounds pretty well
(sometimes you bite in a problem like this, and it could be such easy....
anyway
that causes this problem:
Argument '1': cannot convert from 'ref short' to 'ref object'
u know what I can do here?
thx indeed
mfg Manuel
|
|
|
|
|
Calamitous wrote:
Argument '1': cannot convert from 'ref short' to 'ref object'
u know what I can do here?
API automatically generated by the type lib discoverer comes short in many places, including that one. In fact, you need to know to hack the C++ IDL interface counterpart before you get the C# stuff working.
For your issue, the simplest thing I can see is as follows :
short i = 2; // example
object oi = i;
frame f = X.frames.item(ref oi);
|
|
|
|
|
hi i use ildasm.exe in my tool , how should i do to start it via the .net environment variables?
currently my code looks like
<br />
Process p=new Process ();<br />
p.StartInfo.FileName =@"C:\WINNT\Microsoft.NET\Framework\v1.0.3705\ilasm.exe";<br />
i need to be able to start it via the environment vars and not use a hardcoded path.
so how do i access the environment vars and how would the aboce code look with the environment vars in it?
//Roger
|
|
|
|
|
Call this function[^] via DllImport.
[edit]And I never tried it, but you can try the RuntimeEnvironment.GetRuntimeDirectory method[/edit]
I see dumb people
|
|
|
|
|
oke this solved it halfway..
i need the path for ilasm.exe to... and for some reason ilasm and ildasm are located in differet folders.
"C:\Program\Microsoft Visual Studio .NET\FrameworkSDK\Bin\ildasm.exe"
and C:\WINNT\Microsoft.NET\Framework\v1.0.3705\ilasm.exe
why?
RuntimeEnvironment.GetRuntimeDirectory () returns the path where ilasm is located , but how can i get the other path to? and are they always located at different locations?
//Roger
|
|
|
|
|
Because ILDASM is a programmer tool, it is located on the Framework SDK path, not in the Framework path.
I'm not sure if this is the right way, but you can obtain it at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\sdkInstallRoot
I see dumb people
|
|
|
|
|
Daniel Turini wrote:
sdkInstallRoot
Looks like that would only be part of the SDK. So that wouldn't work if you were installing to a box with only the runtime.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
can i execute "vsvars.bat" first?
vsvars.bat is tha batch file that registers the .net environment variables .
so could i somehow execute that batch in the context of my program so my program can retrive the paths from the environment variables then?
i actually peeked inside a quite wellknown obfuscator (and they use ilasm and ildasm)
and they retrive the path to both of them via the environmentvariable "path" , but that variable dont contain the .net paths unless vsvars.bat have been executed.
(they also display a mysterious dos window before their app starts , and i beleve they actually executes vsvars.bat in there somehow)..
so any ideas how i could start that bat file so that the vars are visible to my app?
//Roger
|
|
|
|
|
Well, there are a couple problems with that. That batch file is only included with the .NET Framework SDK. End-users will only have the .NET Framework Runtime. So they won't have ILDASM or VSVars32.bat.
And, you can run VSVars32.bat, but why not just hardcode the path? I don't think it's gonna change until you upgrade to another .NET Framework version.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
Hi.
How can I colour some rows of a DataGrid?
I have to colour some row where one boolean or more value of the database is
true or false.
Demetrio
|
|
|
|
|
I detect the internet connection with the following method
//*************************************
try
{
server = DNS.GetHostByName("www.yahoo.com");
}
catch(Exception)
{
Console.WriteLine("Internet Connection not found"); // fail
return ;
}
//***********************************************
But it takes times to find if internet connection is up. I need a faster method.
Is there any?
karanba
|
|
|
|
|
Try using the Win32 InternetGetConnectedState() function.
-John
|
|
|
|
|
Can you give me a short code example how to use this function in C#. Is there any resource to add with the project...
thanks.
karanba
|
|
|
|
|
[System.Runtime.InteropServices.DllImport("wininet.dll")]
public static extern bool InternetGetConnectedState(IntPtr lpSFlags, int dwReserved);
if (!InternetGetConnectedState(new IntPtr(0), 0))
{
// not connected
}
|
|
|
|
|
Try and use the following code. Other than the using System.Runtime.InteropServices, I have not added an additional resources to the project. I hope this helps you.
-John
<code>
using System;
using System.Runtime.InteropServices;
namespace CSProject
{
class ConsoleApp
{
[STAThread]
[DllImport("wininet.dll")]
public static extern bool InternetGetConnectedState(double dFlags);
static void Main(string[] args)
{
double dFlags = 0;
bool bResult = InternetGetConnectedState(dFlags);
Console.WriteLine("Internet Connection: {0}", bResult.ToString());
}
}
}
</code>
|
|
|
|