|
Frank Kerrigan wrote: Sorry Colin thats doesn't compile in visual studio 2003
Sorry, I didn't realise you wanted something a bit more retro. Try this:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication3
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
oh cheers it doesn't really do much does it !
|
|
|
|
|
sivaramireddy p wrote: plz send me code
"please" read the top (first) post titled "How to get an answer to your question". Pay attention to item #2.
|
|
|
|
|
|
|
Nice one. Thanks for that.
|
|
|
|
|
Is there a way to make a button look like it is pushed? I want people to know that they have someone on or off.
|
|
|
|
|
RussBus wrote: Is there a way to make a button look like it is pushed? I want people to know that they have someone on or off.
Use a CheckBox control instead and change the Appearanace property to Button .
Upcoming FREE developer events:
* Developer! Developer! Developer! 6
* Developer Day Scotland
My website
|
|
|
|
|
Wow, that's a lot easier than my ideas. I had no idea you could do that!
Jeff
|
|
|
|
|
1. Make your own button class, that inherits from System.Windows.Forms.Button
2. Add a property called "IsPressed" that gets or sets a private member
3. Override the onPaint method, and draw the button based on the value of the private member behind the IsPressed property
If you use flat styles, then you can just make clicking the button swap the button flat style with the previous value to get that kind of effect, but it doesn't look like a standard button then. Another alternative is that you change the text. So, for example, you could change "Show" to "Hide" and vice-versa. Hope one of these ideas helps.
Jeff
|
|
|
|
|
Hi
I am having a COM interface method like this:-
interface IMain : IUknown
{
HRESULT GetInterface([in]IID riid, [out, iid_is("riid")]IUnknown **ppInterface);
}
and importing the idl/tlb to metadata; the above method is translated as follows:-
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void GetInterface([In] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppInterface);
When i call this from the .NET client like this:-
Guid someItfGUID = "6BD5A170-D0DC-4b59-8D86-2651C46CB6CC";
object itfObject = null;
iMain.GetInterfacesomeItfGUID, out itfObject);
IController ctrlr = itfObject as IController;
I see that the itfObject is null even after the call to GetInterface but does not fail on the COM side.
Let me know if you get any idea why itfObject is null [why the IUnknown/IController is not transported across].
Thanks
Vivek Ragunathan
Programming is an art, Code is a poem !!!
|
|
|
|
|
Why do you have a method GetInterface in a COM interface?
|
|
|
|
|
There are various components beside the main component and the main component is responsible for providing access to the other components. Hence a GetInterface.
Programming is an art, Code is a poem !!!
|
|
|
|
|
Well that's what IUnknown::QueryInterface is for. I'm confused
|
|
|
|
|
I am making my first program that has frmMain (parent form) and some more forms that all together, store data (first name, last name, address, city, phone, etc..), search for the employee, edit data, print labels, and more.
I am really new to C# and I need a lot of help.
I am using a file called employee.dat and I am using the tabed style (not sure whats its called). I can save all the information I am just having trouble bringing it back out, and searching for results.
Do I need to use a array, or a arraylist? Also do I need one for every type of data I store (the first name, last anme, address, etc...) or will one do?
Last but not least can you help me with the code to search for the last name of the employee.
The last name field is in value[0], its on btnSearch, in form searchEmployee, with a list box called lstResults.
Thanks in advance for your help.
here is the code for the serialize I used
public string Serialize()
{
return mLastName + "\t"
+ mFirstName + "\t"
+ mMI + "\t"
+ mSSN + "\t"
+ mAddressLine1 + "\t"
+ mAddressLine2 + "\t"
+ mState + "\t"
+ mCity + "\t"
+ mCountry + "\t"
+ mZip + "\t"
+ mHomePhoneNumber + "\t"
+ mCellPhoneNumber + "\t"
+ mOfficeExtension + "\t"
+ mDepartment + "\t"
+ mEmail + "\t"
+ mBirthday + "\t"
+ mAnniversary + "\t"
+ mSpouse + "\t"
+ mEmployeePictureFile + "\r";
}
and the code for the Deserialize.
public void Deserialize(string serialized)
{
string[] values = serialized.Split('\t');
LastName = values[0];
FirstName = values[1];
MI = values[2];
SSN = values[3];
AddressLine1 = values[4];
AddressLine2 = values[5];
State = values[6];
City = values[7];
Country = values[8];
Zip = values[9];
HomePhoneNumber = values[10];
CellPhoneNumber = values[11];
OfficeExtension = values[12];
Department = values[13];
Email = values[14];
Birthday = values[15];
Anniversary = values[16];
Spouse = values[17];
EmployeePictureFile = values[18];
}
-- modified at 11:35 Tuesday 20th November, 2007
Kyle Maldonado
|
|
|
|
|
Presumably you have some sort of struct for each of these records, so just declare a List<> for your struct type. If you will only be searching on last name, then make your struct implement IComparable, and just do a List<>.Sort() on your data. Then use binary search within the list. Otherwise, if the data is reasonably static and you will perform a lot of searches, you may want to index the values and implement multiple IComparers. Hope this helps!
Jeff
|
|
|
|
|
Hi guys!
I'm trying to automate the process of pasting the contents of the clipboard into another window.
Up to now I had two different ways for this: Use SendKeys.Send()/SendKeys.SendWait() or using keybd_event() via P/invoke, and both ways work just fine with virtually every window I could find.
Unfortunately, today I found out that neither of these ways works when having a Terminal Server Client Window (mstsc.exe) as target.
The contents of the clipboard are set correctly, because when I press Ctrl+v manually, the contents do get pasted. But when I try to tell the RDP session that Ctrl+v has been pressed by any of the means above, nothing happens (i.e. the clipboard contents don't get pasted).
Any idea what else I can try?
(oh yes, and for all the newbies:
hlp plz, vrrrry URGENT!!!)
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Try using PostMessage from user32.dll, with WM_KEYDOWN and WM_KEYUP messages. Some windows only respond to asynchronous calls, and I'm not sure if the calls you are mentioned in your post are synchronous or asynchronous. Basically, use Spy++ to see what messages are being passed when you do it manually (almost certainly PostMessage calls) then mimick those. Hope this helps!
Jeff
|
|
|
|
|
Thanks, I'll try.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hi Jeff!
Finally I got to try out your suggestion. Unfortunately it didn't work either.
While I'm able to send key strokes to "regular" windows (notepad for example) using WM_KEYDOWN/WM_KEYUP, nothing is happening when the mstsc window is the target.
Funnily enough, Spy++ doesn't show _any_ keyboard or clipboard messages when monitoring the mstsc window.
Anything else I could try?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Hmm, that is surprising. Are you certain that you matched the events sent to notepad exactly? For example, did you match your keyboard's key identifier for both the keys? Post the code you tried so perhaps I can check for errors? If there were none, then perhaps you could try to show the target window first, as it may be aware of when it has focus, and ignore messages sent when it is hidden.
Jeff
|
|
|
|
|
Hi!
That's part of the code that works with notepad, write, ... as long as I use the HWND of the edit control (for the test program I just got a textbox where I put the HWND I get via Spy++):
[DllImport("user32.dll")]
private static extern bool PostMessage(IntPtr hWnd, int msg, int wPar, uint lPar);
private const int WM_KEYDOWN = 0x100;
private const int WM_KEYUP = 0x101;
private const int VK_V = 0x56;
private void button1_Click(object sender, EventArgs e)
{
IntPtr hWnd = new IntPtr(int.Parse(textBox1.Text, System.Globalization.NumberStyles.AllowHexSpecifier));
bool res;
res = PostMessage(hWnd, WM_KEYDOWN, VK_V, 0x002f0001);
res = PostMessage(hWnd, WM_KEYUP, VK_V, 0xc02f0001);
}
Btw. it doesn't write "v" when I use the HWND of the main application window either, so this could be a hint that WM_KEYDOWN/WM_KEYUP might be inappropriate in this case.
The only thing I haven't tried so far is using SendInput, but I expect it to fail just as keybd_event did. Nevertheless, I'll give it a try.
If you have any further ideas I'd be really grateful.
Thanks,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
ReHi!
Meanwhile I've also tried SendInput(), but, as I expected, it failed just as miserable as all the previous methods did
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I will try to look at this in detail either tonight or Thursday night and give you some more ideas before the weekend...
Jeff
|
|
|
|
|
hi everyone!
i created a windows service. this worked fine. i added an installer projekt. this worked fine as well. then i chose install it completed successfuly, but the service doesn't show up in the service list after installation! so i guess there is something wrong in the installsettings.
i guess it installed correctly but did not register correctly or whatever.
at the moment i do not have a clue what could be wrong. does anyone of you have an idea where i could be looking for?
thanks.
stephan.
|
|
|
|