|
Thank you, this was extremely helpful!
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Hi Folks,
Let me just say I'm a programming newbie. I have this problem that's been irritating me.
I have a list view in my app and I've specified a DataSource for it. I have other functions that are constantly updating the Array that is the DataSource (it's an array of integers, in this case.)
The only way I've found to have the ListView update is to set the DataSource to null and then reassign it. Is there a more elegant way to do this?
Thanks!
|
|
|
|
|
|
Hi,
I've created an icon-file with a 16x16 icon and selected that file in the "Icon" property of my main form. This changes the icon in the top-left corner of the app, but it doesn't change the icon that appears in the ALT-TAB sequence pop-up. I suppose that I need a 32x32 icon for that purpose, but even if I create a such in the icon file - it still doesn't change from the default .Net icon when running the app. Any ideas ?
/Jan
Do you know why it's important to make fast decisions? Because you give yourself more time to correct your mistakes, when you find out that you made the wrong one. Chris Meech on deciding whether to go to his daughters graduation or a Neil Young concert
|
|
|
|
|
Either change the App.ico file in your project, or replace it / add a new icon (presumably the same one as which you designated as your Form.Icon ) and change the Application Icon to reference that icon in your project properties. You should at least have both a 16x16 and 32x32 icon for your .ico file.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
I'm developing a set of Windows form controls that should extend the functionalities of the following classes:
public class MyPushButton : System.Windows.Forms.Button
public class MyCheckbox : System.Windows.Forms.CheckBox
public class MyRadioButton : System.Windows.Forms.RadioButton
I decided to derive a class from each of these base classes in order to get the right notifications from the base class events.
Now these custom controls should apply some graphic effect to the buttons through a set of properties that would be common to all of the "MyXXX" button classes: due to the fact that multiple inheritance is not supported in C#, how can I avoid to have all of the properties and their get/set helpers duplicated in each of the "MyXXX" classes?
Thanks in advance and Kind regards
Seve
|
|
|
|
|
|
does any one of u know a
free-ware tool that can
test software. i.e
does its black box, white box,
regression or other type of testing
|
|
|
|
|
|
OK
After some serious research i've managed to display some balloon tooltips on a notifiyicon, hooked up to a windows form.
But i inteded to write a windows service instead of a form-based application.
Since you need a window handle to run the shell_notifyicon function, needed to display the balloon tooltips, and i don't seem to find the handle from a service, i have a problem
Does anybody know how to get the handle from a windows service, or any way to hook up a balloon tooltip to the notifyicon from a service??
Thx in front
Jochen
|
|
|
|
|
A Windows Service doesn't have a Window handle, so you'll have to P/Invoke GetDesktopWindow :
[DllImport("user32.dll")]
private static extern IntPtr GetDesktopWindow(); Your service, if run as LocalSystem, will also have to have the "Allow service to interact with desktop" option checked in the Service snap-in. See your Control Panel\Administrative Tools for the snap-in.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello,
http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/
I don't know if any of you are familiar with Dino Esposito article in MSDN magazine on .NET Hooks but I used the class he created named LocalWindowsHook that imports the below API calls
protected static extern IntPtr SetWindowsHookEx(HookType code,
HookProc func,
IntPtr hInstance,
int threadID);
and a few other necessary functions from user32.dll to implement a hook.
I ended up changing his Install function from
public void Install()
{
m_hhook = SetWindowsHookEx(
m_hookType, m_filterFunc,
IntPtr.Zero,
(int)AppDomain.GetCurrentThreadId());
}
to
public void Install()
{
m_hhook = SetWindowsHookEx(
m_hookType,
m_filterFunc,
GetHInstance(),
0);
}
public static IntPtr GetHInstance()
{
return Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0]);
}
In an attempt to create a global hook using WH_KEYBOARD.
The problem I have is it doesn't work. It works globally with WH_KEYBOARD_LL but as soon as I use WH_KEYBOARD it doesn't work at all. This meaning it doesn't capture keyboard strokes in either the windows form or anywhere else. Now Dino's code worked fine for a local hook (aka the form) but I want a global or system hook.
Now I have the class he wrote in an external DLL but there must be something else i am missing. If anyone has any suggestions they would be very much appreciated.
Thanks very much.
Dino Esposito modified project and my test windows form can be found here
http://scaninc.ca/hook/globalhook.zip
|
|
|
|
|
The WH_KEYBOARD_LL hook is called in your app. context so can easily be made in C#.
A global WH_KEYBOARD hook however executes in teh context of the app. that is recieving the keyboard message so your code has to be injected into every running process. This is NOT a good idea IMHO. It only seems to work if the m_filterfunc is exported from the DLL in the [EXPORTS] table.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hmm.. I don't believe this is the case.
If a hook is in place globally whether it is WH_MOUSE or WH_KEYBOARD or WH_KEYBOARD_LL the hook functions the exact same for each case. Nothing is injected into any running process, it doesn't work like that. A hook is ultimately a callback function that applications register with a particular system event. It is not injected into every running process as you say. Doing this with C# is no different then any other language as I am just using the windows API.
Now I have the code that can capture WH_MOUSE events at the thread or local application level but I need them to be captured at the global or system level. Any suggestions?
|
|
|
|
|
I take it you have read the MSDN article on hooks? It states:
....This is because global hook procedures are called in the process context of every application in the desktop, causing an implicit call to the LoadLibrary function for all of those processes....
If you only want to be aware of mouse or keyboard events system wide use a WH_JOURNALRECORD hook. Otherwise write your hook stuff in a standard DLL with an EXPORTS section.
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
I have a custom graphic file format for my application. I would like to write a shell extension so that it shows in the Thumbnail Preview in Windows Explorer.
I would also like to write a browser plugin so that when users click on the file, instead of the save or open dialog, it shows in the browser.
Where should I start? Pointers are welcome.
|
|
|
|
|
To have the shell extract an image for your document, you must register an IconHandler and implement IExtractImage , as well as the necessary icon handler interfaces. For more information about the IExtractImage interface, which you can declare in .NET using COM interop, see http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/ifaces/iextractimage/iextractimage.asp[^]. For more information about creating icon handlers, see Creating Icon Handlers[^] in MSDN. This can all be done via a CCW (COM-Callable Wrapper) in .NET, but you'll have to re-declare all the interfaces, structs, and constants necessary. Fortunately, there isn't too many in this case.
As far as writing a browser plugin, that gets a lot more complicated and you might consider doing this in C++ because there's a lot of interfaces, structs, and constants that you'll need to use. It's not that you can't do it in .NET, just make sure you fully understand COM interoperability in .NET.
This uses MIME handlers to host controls like Acrobat, or your document has to be an Active Document like Word and other Office formats. For more information and documentation on MIME handlers (asynchronous pluggable protocols), see About Asynchronous Pluggable Protocols[^]. For more information about Active Documents, see http://msdn.microsoft.com/library/en-us/vccore/html/vcconactivedocuments.asp[^]. Internet Explorer, BTW, is an Active Document Container and can display Active Documents, as well as host any toolbars if they're exposed properly. Other containers like Word, Excel, PowerPoint, and even a few non-MS container applications could also container your document. This requires that your document class implements a few COM interfaces and that your document server is registered using regasm.exe or some other installation utility. Some custom registry editing (see the Microsoft.Win32.RegistryKey class) will be required.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
I have created a windows application in CSharp that is using a web browser control.
When i did some coding to handle a chat window an exception was thrown with the following message:
"COM object that has been separated from its underlying RCW can not be used"
The chat browser window is constantly updating its content automatically.
My question is how can i work around this problem?
I appreciate any help you can give me.
Yours sincerely
Andla
|
|
|
|
|
I have several different tables with textboxes
I want user fill out some information into those boxes and after hit save, I
want to store all those values from those textboxes into database
I don't know why after I hit button save, all the values are gone. Pleaes
tell me how i can keep those values? We
Thanks
|
|
|
|
|
Is that ASP.NET? So you should post it there.
I think you have to set AutoPostback property to false for those textboxes.
Mazy
No sig. available now.
|
|
|
|
|
Set EnableViewState to true and in the server event handler for the "Save" button (or whatever you call it), gather the values from each TextBox and save them to a database using ADO.NET. Search the CodeProject web site for examples. There's also several examples of inserting data into a database from ASP.NET using ADO.NET. For example, if you have a couple TextBox es on the page and a button with the Client event handler save_Click , you could do something like the following:
private void save_Click(object sender, EventArgs e)
{
if (!IsValid) return;
SqlConnection conn = new SqlConnection("...");
SqlCommand cmd = conn.CreateCommand();
cmd.CommentText = "INSERT INTO Table1 (FirstName, LastName) " +
"VALUES (@FirstName, @LastName)";
cmd.Parameters.Add("@FirstName", SqlDbType.NVarChar, 40).Value = textBox1.Text;
cmd.Parameters.Add("@LastName", SqlDbType.NVarChar, 40).Value = textBox2.Text;
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception e)
{
DisplayError(e.Message);
}
finally
{
conn.Close();
}
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for posting.
I really appreciate your time. My problem here is a littl bit different. All those textboxes are creating during running time. Tables (or datagrids not bond from data),
are an array of tables (or datagrids).
I fill all those datagrids(tables) into a place holder.
I'm really frustrated now. I just created another version which does not use datagrid. I use Table of Web Control, everything seemed work fine until I started collecting data. Fromdate, todate have textboxes for user to enter values. I have a submit button, I don't know why everytime I hit button, all the values are gone. My best guess is whenever i hit the button the application has to postback, therefore my array of datagrids(or web tables) are NULL.
Is there a way that I can collect data from these tables (remember these tables are also dynamically change; hence I need help so much, I never built any programatic talbes like these before)
Month fromdate todate Values
Month1
Month2
Month3
Month4
Month5
Month6
Month7
Month8
Month9
Month10
Month11
Month12
--------------------------------------------------------------------------------
|
|
|
|
|
First of all, in order to get values from dynamically generated controls you can either follow the steps I'll discuss after this, or use Request.QueryString for GET requests, Request.Forms for POST requests, or Request.Params if you don't care which HTTP method the parameters come through. Since each is a collection, you can either enumerate all the values and sort out what is what using the names and values, or access the values using the name (like Request.Params["Month1"] ).
Second, in order to keep the controls on the page, you must make sure that in Page_Load you are not clearing the controls or re-binding them when you don't want to by using the IsPostBack property. On the first request to the page, this property is false so bind any data / generate controls. If a user submits the page form, this property is true so skip all that stuff, but only if you've set EnableViewState for the page and other controls to true (which is the default).
For more information, see Page.EnableViewState Property[^] (includes example), Page.IsPostBack Property[^] (includes example), and a nice little article that should help tie them all together, Taking a Bite out of ASP.NET ViewState[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Is there a way to add methods with a wizard. For instance, if I drop a button on the form, double click on the button the code....(assuming the button name is calculate)
private void calculate_Click(object sender, System.EventArgs e)
How can I add other methods like when the mouse moves over it or when the button gets the focus. VC++ 6.0 had a wizard to add event handlers.... what does C# have?
Thanks
Ralph
|
|
|
|
|
There isn't such a thing in C#. You can add other handlers through property grid for the controls.
Mazy
No sig. available now.
|
|
|
|