|
Glad to help. There may be a similar app here on CP. Try searching the site using the google advanced search pointed here.
quorum pars magna fui
|
|
|
|
|
Hey i was wondering if anyone could give me a link or book name that has C#/DirectX 9.0 tutorials.
Yes, Shock I know you are doing them here but I have already done them and figured out DirectInput and was hoping for a more fast paced tutorial. I can help wiht DInput if you like.
|
|
|
|
|
I have a TextBox that is part of a control (toolbar) that is part of another
control (an Explorer band object); no forms involved. This TextBox is
defined thus:
this.searchTextBox.Location = new System.Drawing.Point(48, 24);
this.searchTextBox.Name = "searchTextBox";
this.searchTextBox.Size = new System.Drawing.Size(168, 20);
this.searchTextBox.TabIndex = 4;
this.searchTextBox.Text = "";
does not process the Backspace key. Another TextBox that is part of a
dialog box does function correctly, defined thus:
this.urlTextBox.Location = new System.Drawing.Point(8, 8);
this.urlTextBox.Name = "urlTextBox";
this.urlTextBox.Size = new System.Drawing.Size(232, 20);
this.urlTextBox.TabIndex = 0;
this.urlTextBox.Text = "";
Both were defined by the Designer, nothing fancy.
Why is the Backspace key not handled automatically in the first case? What
do I have to do to make it work? Interestingly, the Delete key does work
fine.Also interestingly, when I press the Backspace key, only the KeyUp
event is fired, not also the KeyDown and KeyPress events like most other
keys. Even if I wanted to manually handle the Backspace key within a KeyUp
event hander, I have no idea how to locate the position of the caret within
the TextBox's string. Of course, it'd be far preferable to have the TextBox
behaving normally.
Thanks,
Arun
|
|
|
|
|
So I came up with a mediocre workaround, using the OnKeyUp event handler:
private void searchTextBox_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Back)
{
if (searchTextBox.SelectionLength > 0)
searchTextBox.SelectedText = "";
else if (searchTextBox.SelectionStart > 0)
{
int caret = searchTextBox.SelectionStart;
searchTextBox.Text = searchTextBox.Text.Substring(0, caret - 1) +
searchTextBox.Text.Substring(caret);
searchTextBox.SelectionStart = caret - 1;
}
e.Handled = true;
}
}
I don't think it's a great workaround because it seems to be handled in a sluggish way. Plus, I can't hold down the Backspace key and have it delete a whole bunch of characters in a row like I can with the Backspace key.
Strangely, for this instance of the TextBox control, the Backspace key is not handled by the KeyDown or KeyPress events, unless modified by another key (e.g., Control, Shift, Alt).
Any tips would be great.
|
|
|
|
|
Hi
This one has me completely confused. What is the correct way of doing this? I have some "rules" I want to stick with.
- Designer support
- Object must be a singleton
Now these 2 are conflicting
Here's my possible solution:
public class Singleton : Component
{
private static SingletonInternal instance = null;
private static int instancecount = 0;
private class SingletonInternal : IDisposable
{
public void SomeMethod()
{
}
public void Dispose()
{
}
}
public Singleton()
{
if (instance == null)
instance = new SingletonInternal();
instancecount++;
}
public void SomeMethod()
{
instance.SomeMethod();
}
protected override void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
}
instancecount--;
if (instancecount == 0)
instance.Dispose();
this.disposed = true;
}
}
}
Is this the way to go? All comments welcome
Cheers
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
I think you want something along these lines...
public class Singleton : Component
{
private Singleton m_instance = null;
private Singleton(){} // constructor is private so it can't be created externally
public static Instance()
{
if(!m_instance)
m_instance = new Singleton;
return m_instance;
}
}
Your instance counting and dispose logic should still work. To use it, you dont create a new Singleton, but rather use Singleton s = Singleton.Instance();.
-pete
|
|
|
|
|
pete mcquain wrote:
private Singleton(){} // constructor is private so it can't be created externally
That is where it wont work in a designer...
MyDUMeter: a .NET DUMeter clone "Thats like saying "hahahaha he doesnt know the difference between a cyberneticradioactivenuclothermolopticdimswitch and a biocontainingspherogramotron", but with words you have really never heard of."
|
|
|
|
|
Hello,
I'm using the webbrowser control in an application where the crawling is totally automated.
The problem is that sometimes the browser try to crawl an archive file or whatever. In that case a security alert dialog box pops up and my webbrowser control waits for this dialog to close.
I already succeded removing all Javascript dialogs by implementing the IDocHostShowUI interface and by putting the control into the "silent" mode (put_silent()).
I also implemented the IDocHostUIHandler to return S_OK or S_FALSE wherever possible to get rid of a maximum of MSHTML UI unwanted behaviours.
But I still get this security alert dialogs and I have no ideas of how to avoid them.
The only solution I found for the moment is to filter the links the webbrowser control can crawl in a page by removing files containing 'zip','rar','mp3','jpg','gif'... And so on.
But this solution is not perfect because of the number of possible file types and because sometimes you can't even guess what it is from the URL.
If only the webbrowser control could allow me to access the HTTP file headers before display, to guess what it is from the content-type !
But even if I can filter the URL I crawl, I would really like a solution to remove the security alert dialogs.
I also tried to tweak the Internet Explorer options to avoid prompts and dialogs but I didn't solve this problem.
Any idea ?
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
GriffonRL wrote:
But even if I can filter the URL I crawl, I would really like a solution to remove the security alert dialogs.
I also tried to tweak the Internet Explorer options to avoid prompts and dialogs but I didn't solve this problem.
If you have an automatic crawler, why should you have anything displayed while you are crawling ? If you have anything displayed, Internet Explorer runs in "interactive" mode, and I believe ActiveX security boxes are hardwired in this mode.
It is possible to use Internet Explorer like a COM dll : see a MSDN sample called "WalkAll".
|
|
|
|
|
Hello Stephane,
If I am right WalkAll use MSHTML only not the WebBrowser control.
The problem if that I lack a lot of features if I use MSHTML instead of the WebBrowser control. I would need to implement all the navigation stuff and more.
Moreover, even if this is an antomatic crawler, I sometimes switch to some manual control.
Nevertheless thanks for the answer.
Any other idea ?
Regards,
R. LOPES
Just programmer.
|
|
|
|
|
GriffonRL wrote:
If I am right WalkAll use MSHTML only not the WebBrowser control
Yes, I would use monikers to get the content pointed by the URL, retrieve the data then throw it at an actual web browser instance (where I would simply do a IPersistFile->Load(...) or something like that).
The fact that you see the data makes you have the opportunity to strip off all messing tags, if required. (you need an html parser).
GriffonRL wrote:
Any other idea ?
Become a hacker . You have to find the way to make the Internet Explorer temporarily switch to low-security mode, where ActiveX and stuff are all ok.
|
|
|
|
|
I hope you will not laugh but I have some problems regarding a very simple applications...
I have an application which requiers the user to logon supplying a username and a password.
That is done by the first Form (frmLogin).
If the user supplies the correct logon information I have to:
- open a new Form with the Application itself (frmApp)
- close the logon form (frmLogin)
The problem is that after I make the Application Form visible (frmApp) and eventualy want to close it, it dissapears from the screen but the application is still running on the background (a processes is still active in the task manager).
Can you help me?
Thanks in advance,
Vlad Mihai
|
|
|
|
|
when you want to quit the program, do this.
Application.Exit();
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
Vlad,
How are you closing the Application? Are you just using frmApp.Close()? This may be the source of your issue. Try using Application.Exit() instead. This will tell all message sources in your app to terminate and will close all open windows of your app.
Good luck.
quorum pars magna fui
|
|
|
|
|
Thanks guys...
There is a problem though. I am a newbye and used only to Java
In java there was an event called Window.Closing associated to the closing of the Window (that X in the top-right corner )
Is there something like this in C# ?
My application was supposed to close when i clicked on that X of the Form.
How can I associate then this X with Application.Exit?
Thanks again
|
|
|
|
|
Yes.
In C# you use delegates to register your event handlers. It looks and works a lot like java.
this.Closing += new System.EventHandler(yourClosingMehtod);
where yourClosingMehtod should have a signature like
yourClosingMehtod(object sender, EventArgs e)
quorum pars magna fui
|
|
|
|
|
I have a main form with a main process that evaluate ever the same proc "MyMethod", ok, but.. this method are store in another class. (ok too)
The Problem.. This "another" class are ever a UserControl,, but i make several copies of thies UserControl and change some layout properties on each one (screen1, screen2)
The unique difference between these screenX are the graphic layout. (This are what i need the graphical properties values)
But,,, How can i do to "switch" the call to MyMethod in order to the "current" screenX object.
The "current" screen is variable.
Of course screen(x) can be 100. I need to do it in a dinamic way.
Here are an aproach to the problem (i wrote this code without test it..)
Note the ????
-------------------------------------------------------------------------------------
using System;<br />
using System.Windows.Forms;<br />
namespace myApp<br />
{<br />
public ???? activeScreen <br />
<br />
public class myApp : System.Windows.Forms.Form<br />
{<br />
public mYApp() {<br />
<br />
<br />
int value = 1;<br />
<br />
switch(value) {<br />
case 1:<br />
Console.WriteLine(activeScreen.MyMethod());<br />
break; <br />
<br />
case 2:<br />
Console.WriteLine(activeScreen.MyMethod());<br />
break;<br />
} <br />
}<br />
}<br />
} -------------------------------------------------------------------------------------
using System;<br />
using System.Windows.Forms;<br />
namespace myApp<br />
{<br />
public class Screen2 : System.Windows.Forms.UserControl<br />
{<br />
public Screen2()<br />
{<br />
<br />
}<br />
public int MyMethod() {<br />
int value = 2;<br />
return value;<br />
}<br />
}<br />
}
-------------------------------------------------------------------------------------
using System;<br />
using System.Windows.Forms;<br />
namespace myApp<br />
{<br />
public class Screen1 : System.Windows.Forms.UserControl<br />
{<br />
public Screen1()<br />
{<br />
<br />
}<br />
public int MyMethod() {<br />
int value = 1;<br />
return value;<br />
}<br />
}<br />
} -------------------------------------------------------------------------------------
|
|
|
|
|
There is an ActiveForm property that returns the active form for the app, so you could do.
Form.ActiveForm.MyMethod();
and you activeScreen can be of type Form.
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
I need to know how to detect the installed version of Microsoft Office (especially Outlook). Cause i have written a class to bypass the "Outlook Object Model Guard" and create addins for Outlook. But i need first to know which version of Outlook (XP or 2002) and which Office service pack are installed.
Does anyone have an idea ??
I think using registry is a good solution but is there any best way to do that ??
Thanks in advance.
Hawkmoon.
|
|
|
|
|
A few tips :
- More than one Office version may be installed
- Lookup HKLM\Software\Microsoft\Office\xxx\Excel\InstallRoot\Path="c:\....\Excel.exe". Where xxx is 10.0 (XP) , 9.0 (2000), 8.0 (97), ...
- this key tells you which Excel version is installed. It's up to you to check the provided path actually points or not to an existing Excel.exe file. To make sure that the retrieval works fine, combine this key with those from other Office apps, including Word, Powerpoint, Access, Outlook (due to a custom install).
- if you need to know which service-pack is installed, that's somewhat tougher. There are documented papers on the MS site for this purpose, but from my former code I can tell the fastest and easiest way to do so is to check the dll file version (xx.yy.[SSSS].zz) of the Office run-time (mso.dll on OfficeXP, mso9.dll on 2K, mso97.dll on 97, ...)
|
|
|
|
|
Thanks for all )
Hawkmoon
|
|
|
|
|
I want to display a window form inside another form
Please tell me how can i do that.
Thanks in advacne
|
|
|
|
|
I'm not quite sure what you mean faad.
If you are trying to display another windows form, you can use Form.Show().
If you are trying to run an external process you need to look at the System.Diagnostics.Process class and use the Process.Start() method.
Good luck
quorum pars magna fui
|
|
|
|
|
I have different forms in my application
there is a main form.
There is a splitter on the main form.
on left side when a button is clicked i want to display a form on the right side,and then change the right side form on each click.
|
|
|
|
|
Why not use the button click event to Show th componets?
quorum pars magna fui
|
|
|
|