473,322 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Assign a Unique ID to a Win Forms Control

How do I assign a unique Id (like WM_USER+nnn) to a control?
Nov 17 '05 #1
4 3433
Hi John,
How do I assign a unique Id (like WM_USER+nnn) to a control?


I am not entirely clear about the meaning of "a unique Id on a WinForm
Control", could you please elaborate what do you want to do with that
unique Id?

Generally speaking, the .NET's WinForm controls do not like the traditional
Window 32 controls in an unmanaged application. In a .NET WinFrom
application, they are created as private member variables of their
contained WinForm class and use the "Name" property(the name of the
corresponding member variable) to identify themselves instead of a resource
ID(note: they are not resource items the .NET WinFrom project).
Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #2
I'm a newbie the Managed VC++, after 11+ years of Windows and MFC. so bare
with me..

I have a WinForm that has 6 Buttons that have a lot of commonality between
them. When Clicked, I would like the same Event Handler Function to handle
all 6 Buttons and use a switch statement to handle to specifics for a given
Button. To me this seems like much less code having 6 Event Handler
Functions.

The second part of the issue is, in the Event Handler Function, how do I do
the equivalent of casting the Syetem::Object *s to Button *b so I can get at
the Button's (or any sender's) variables.

Thanks

JEK

"Gary Chang[MSFT]" <v-******@online.microsoft.com> wrote in message
news:p0**************@TK2MSFTNGXA01.phx.gbl...
Hi John,
How do I assign a unique Id (like WM_USER+nnn) to a control?


I am not entirely clear about the meaning of "a unique Id on a WinForm
Control", could you please elaborate what do you want to do with that
unique Id?

Generally speaking, the .NET's WinForm controls do not like the
traditional
Window 32 controls in an unmanaged application. In a .NET WinFrom
application, they are created as private member variables of their
contained WinForm class and use the "Name" property(the name of the
corresponding member variable) to identify themselves instead of a
resource
ID(note: they are not resource items the .NET WinFrom project).
Thanks for your understanding!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default...sdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no
rights.

Nov 17 '05 #3
Hi John!
I have a WinForm that has 6 Buttons that have a lot of commonality between
them. When Clicked, I would like the same Event Handler Function to handle
all 6 Buttons and use a switch statement to handle to specifics for a given
Button. To me this seems like much less code having 6 Event Handler
Functions.

The second part of the issue is, in the Event Handler Function, how do I do
the equivalent of casting the Syetem::Object *s to Button *b so I can get at
the Button's (or any sender's) variables.


The easiest approch is to use one Event handler with using the
sender-object to determine the different buttons:

<code>
private: System::Void buttonX_Click(
System::Object * sender,
System::EventArgs * e)
{
Button *btn = dynamic_cast<Button*>(sender);
if (btn == button1)
{
MessageBox::Show(this, S"Button1");
}
else if (btn == button2)
{
MessageBox::Show(this, S"Button2");
}
else if (btn == button3)
{
MessageBox::Show(this, S"Button3");
}
else if (btn == button4)
{
MessageBox::Show(this, S"Button4");
}
}
</code>
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #4
Hi John,

I was reviewing the issue thread. Jochen has replied with code samples on
it. Is there any question on it? If yes, please feel free to post here and
we are glad to work with you.

Thanks very much for participating the community.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Tony Clarke | last post by:
Hi, I'm trying to write a system thats used for about 50 clients that uses html forms and php to log details. The problem is that when a client loads the form page it's given a value which is...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
0
by: amywolfie | last post by:
Hi all: I have a subform called sfrmFootnotes linked to main Form frmFeeInput (the latter based on tblFees). tlkpFootnotes contains the PK for Footnotes. tjnCode_Footnotes is a join table...
2
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
0
by: PontiMax | last post by:
Hi, when we used VB 6 to build all kinds of applications we applied the following technique to automatically assign resource strings to ui controls: Each control has a unique resource id (which...
1
by: Marc | last post by:
Hi! I'm working with a C# client that calls a php web service. I've created a wrapper to call the service using .NET wsdl tool (adding a web reference). The call to the server works fine, it...
2
by: dBNovice | last post by:
Hi all! I have 3 separate forms: Tasks, Subtasks, and Elements. All 3 is related by TaskId and Subtasks and Elements are related by SubtaskID. In the DB after I add a task, I want to be able to...
5
by: SBC News Groups | last post by:
Using VBA how do I assign columns from a table to controls on an unbound form? Mike
10
by: wilhelmmt | last post by:
My database tracks submission requests from customers. I have a parent form (frmSubmitterLibrary) and a subform (frmSubmissionRequest) which is based on a table (SubmissionTable). The ClientID links...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.