|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
?creating activex control?I've created one, with textbox inside. When I use it in my app on property
windows I have (for example) parametar Aligment as integer but I need to have like in textbox "0 - Left Justify". The same is with appearance, border style... What must I do? Thanks, J if you make our ENUMs like this:
Public Enum BorderStyleConstants ccNone = MSComctlLib.BorderStyleConstants.ccNone ccFixedSingle = MSComctlLib.BorderStyleConstants.ccFixedSingle End Enum Public Enum AppearanceConstants ccFlat = MSComctlLib.AppearanceConstants.ccFlat cc3D = MSComctlLib.AppearanceConstants.cc3D End Enum and make your properties like this: Public Property Get Appearance() As AppearanceConstants Appearance = UserControl.Appearance End Property Public Property Let Appearance(ByVal New_Appearance As AppearanceConstants) UserControl.Appearance() = New_Appearance PropertyChanged "Appearance" End Property you can simulate the standard way. Martin de Jong Show quoteHide quote "_john_" <j***@microsoft.com> schreef in bericht news:dinq55$28e$1@ss405.t-com.hr... > I've created one, with textbox inside. When I use it in my app on property > windows I have (for example) parametar Aligment as integer but I need to > have like in textbox "0 - Left Justify". The same is with appearance, border > style... > > What must I do? > > Thanks, > J > > Hi J:
In addition to what Martin posted... Some properties (like alignment, multiline, etc.) can not be changed at runtime. So in your case, you would probably have to use a separate usercontrol for each different case, or have different textboxes on your control (which, imho, is huge waste of resources) that has each of the desired property configurations. You will have to experiment to see which properties you can change at runtime. Doug. Show quoteHide quote "_john_" <j***@microsoft.com> wrote in message news:dinq55$28e$1@ss405.t-com.hr... > I've created one, with textbox inside. When I use it in my app on property > windows I have (for example) parametar Aligment as integer but I need to > have like in textbox "0 - Left Justify". The same is with appearance, border > style... > > What must I do? > > Thanks, > J > > Or, if you're somewhat masochistic, you can host an API edit control
in the usercontrol which would allow you to destroy the existing control and create a new one if the user changed a property that must be supplied when the control is created. HTH, Bryan _______________________________ Bryan Stafford New Vision Software newvision_don'tspam@mvps.org On Fri, 14 Oct 2005 07:54:08 -0600, "Douglas Marquardt" <no_spam@dummy.com> wrote: Show quoteHide quote >Hi J: > >In addition to what Martin posted... > >Some properties (like alignment, multiline, etc.) can not be changed at runtime. >So in your case, you would probably have to use a separate usercontrol >for each different case, or have different textboxes on your control >(which, imho, is huge waste of resources) that has each of the desired >property configurations. > >You will have to experiment to see which properties you can change at >runtime. > > >Doug. > > >"_john_" <j***@microsoft.com> wrote in message news:dinq55$28e$1@ss405.t-com.hr... >> I've created one, with textbox inside. When I use it in my app on property >> windows I have (for example) parametar Aligment as integer but I need to >> have like in textbox "0 - Left Justify". The same is with appearance, border >> style... >> >> What must I do? >> >> Thanks, >> J >> >> > "_john_" <j***@microsoft.com> wrote in message As others mentioned, you can use Enums to get intellisense. Textbox news:dinq55$28e$1@ss405.t-com.hr... > I've created one, with textbox inside. When I use it in my app on property > windows I have (for example) parametar Aligment as integer but I need to > have like in textbox "0 - Left Justify". The same is with appearance, > border style... > > What must I do? > > Thanks, > J alignment constants are part of the "RUN.AlignmentConstants" enum. 'If you define your property like this, you'll have Intellisense and will be using the same constants the textbox uses. '======= 'btw, the 'me' prefix is... module scope, enum value... it's not referring to "myself" <g> Private meAlignment As VBRUN.AlignmentConstantsPublic Property Get Alignment() As VBRUN.AlignmentConstants Alignment = meAlignment End Property Public Property Let Alignment(ByVal Setting As VBRUN.AlignmentConstants) meAlignment = Setting End Property '======= One problem with Martin's suggestion is.... the way it's coded, it would require you to add 'Microsoft Windows Common Controls' to your project and most likely package it up with your app so the control knows what "MSComctlLib.BorderStyleConstants" are. Ok.... now for the bad news. There's a bug in VB that's allowing you to set that property at runtime. Help says it's read-only at runtime. That means, all bets are off when it comes to behavior. The "usual" method is to create an array of 3 textboxes (0-2), each with their own alignment setting (left/riight/center) and hide/show the correct one based on setting the user selects. Some people suggest creating 3 controls... I'd rather stick with a single control that contains multiple textboxes. You'll have to do something like that anyway if you want support for a Single/MultiLine property. -- Ken Halter - MS-MVP-VB - http://www.vbsight.com DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Please keep all discussions in the groups.. "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message I always assumed it was an 'undocumented enhancement' rather than a bug.news:u32Z54M0FHA.2212@TK2MSFTNGP15.phx.gbl > There's a bug in VB that's allowing you to set that property at > runtime. Help says it's read-only at runtime. The only issue with changing it at runtime is that it can cause spurious Change events with garbage contents. For example: Private Sub Form_Click() Debug.Print "Form_Click" Text1.Alignment = vbCenter Debug.Print "Alignment changed" End Sub Private Sub Form_Load() Text1.Text = "Set Text Property" End Sub Private Sub Text1_Change() Debug.Print "Text1_Change=" & Text1.Text & " [" & Text1.hWnd & "]" End Sub Run it, click on the form and you get this output: Text1_Change=Set Text Property [591630] Form_Click Text1_Change=Text1 [657166] Text1_Change=Set Text Property [657166] Alignment changed Since Alignment can only be changed when the control is created VB has to destroy it, create a new window (during which it sets the default value) and then restore the contents. If your code relies on the Change event or the hWnd then you have to allow for that when changing Alignment. -- Reply to the group so all can participate VB.Net: "Fool me once..." Did you create your control from the scratch? From another thread I posted
to: Try going to Add-ins|Add-in Manager, and select "VB ActiveX Control Interface Wizard" and make sure it's loaded. You could make it also load on startup for convenience. Now go to Add-ins|VB ActiveX Control Interface Wizard, and select what properties and methods you would like. By default, it selects commonly used properties and methods. After you finish, it will create the code for you. You will find it easier to add to that code by just copying and pasting and modify the code as it suites you. If you don't understand a particular item, just press F1 for help... Note that you don't have to make a UserControl as an OCX in order to use it in an EXE. In your Standard EXE project, just go to Project-->Add User Control, and start making your control, just as if you were making an OCX. To place your UserControl on a form, such as Form1, you have to close the UserControl design window(Not the code), and place the control on Form1. VB would have added an additional icon to the ToolBox when you added the UserControl, it's grayed out when the UserControl design window is open. If you have already made the control as an OCX, then in your Standard EXE project, go to Project-->Add File, and browse to where you put the usercontrol. Note that It's best to copy the UserControl file first to the folder where you keep your project(or a subfolder) if it was elsewhere. Now your control would be part of the EXE and nobody can see or use your control, it's part of the EXE and not exposed outside the EXE. I have made a fancy 3D button using this method, works great. Show quoteHide quote "_john_" <j***@microsoft.com> wrote in message news:dinq55$28e$1@ss405.t-com.hr... > I've created one, with textbox inside. When I use it in my app on property > windows I have (for example) parametar Aligment as integer but I need to > have like in textbox "0 - Left Justify". The same is with appearance, > border style... > > What must I do? > > Thanks, > J > On Fri, 14 Oct 2005 15:03:07 -0400, "Someone" <nob***@cox.net> wrote: <snip>Show quoteHide quote >Note that you don't have to make a UserControl as an OCX in order to use it I strongly agree with 'Someone'>in an EXE. In your Standard EXE project, just go to Project-->Add User >Control, and start making your control, just as if you were making an OCX. >To place your UserControl on a form, such as Form1, you have to close the >UserControl design window(Not the code), and place the control on Form1. VB >would have added an additional icon to the ToolBox when you added the >UserControl, it's grayed out when the UserControl design window is open. > >If you have already made the control as an OCX, then in your Standard EXE >project, go to Project-->Add File, and browse to where you put the >usercontrol. Note that It's best to copy the UserControl file first to the >folder where you keep your project(or a subfolder) if it was elsewhere. Now >your control would be part of the EXE and nobody can see or use your >control, it's part of the EXE and not exposed outside the EXE. > >I have made a fancy 3D button using this method, works great. - making OCXes creates more installation work - the OCX 'wrapper' is a tremendous bloat - it is much easier to write and tweak a UserControl when it is included in the project rather than set up as an OCX UserControls are wonderful, OCXes are a PITA Now what would be really useful would be if the comiler had an option for ripping out the active code in an OCX and inserting it into the main EXE - rather like using LIB files
Difference in SQL Syntax between Access and MySQL (from VB6 project using ADO)
Ping Ken Halter Font Dialog Box kill a proccess for a specific user VBA and ADODB.Recordset question Software protection against cracks and piracy Resizing text boxes user-defined type not defined Determine when report printed to specific printer Searching for text in Text boxes |
|||||||||||||||||||||||