Showing results 1 to 4 of 4

Thread: Accessing the rgm recipe name combobox

  1. #1
    andreacold Gast

    Default Accessing the rgm recipe name combobox

    Hi,
    i need to access the rgm recipe name in the standard RGM page but i'm not able to do it.
    this is my actual code:

    Public Sub test()
    
        Dim i, nProps, obj
        Dim tmp_str As String
        
        Set obj = thisProject.DynPictures.Item("RGM").Elements.Item("Recipe_name")
        
        nProps = obj.DynPropertiesEnum("")
            
        For i = 0 To UBound(nProps)
            tmp_str = tmp_str & i & ")-" & nProps(i) & Chr(13) & Chr(10)
        Next i
        
        Debug.Print tmp_str
        
    End Sub

    This way i can access all the dynamic properties of the combobox that contains the name of the recipe but i can't see how i can read its current value.
    Thanks in forward for any tip.
    Have a nice day

    Andrea

  2. #2
    robertf Gast

    Default Re: Accessing the rgm recipe name combobox

    Most of the DynProperties are not available for Elements at Runtime, but you can try to use a code like the following...

    This Code uses API Functions to get the WindowText of the RECIPE - COMBOBOX.

    '**********************************************************************
    '* This codesample reads the value out of a MDI-Element, by using     *
    '* Windows API functions                                              *
    '* ------------------------------------------------------------------ *
    '* Autor: Robert Ficker                                COPA-DATA GmbH *
    '**********************************************************************
    Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Dim lpString As String
    Dim cch As Long
    Dim ActRecipe As String
    
    Public Sub LeftClickUp_Button(obElem As Element)
        '******* Create string filled with null characters *******
        lpString = String$(255, vbNullChar)
        '******* Return length of string *******
        cch = Len(lpString)
        'in this sample "COMBOBOX" is the name of the combobox-element in the RGM picture...
        ActRecipe = Mid(lpString, 1, GetWindowText(obElem.Parent.Item("COMBOBOX").hwnd, lpString, cch))
    End Sub

    I hope this sample helps...

  3. #3
    andreacold Gast

    Default Re: Accessing the rgm recipe name combobox

    Thank you very much Robert, it works perfectly!
    Keep up the good work, have a nice day.

    Andrea

  4. #4
    Join Date
    20.08.2009
    Posts
    293

    Default AW: Accessing the rgm recipe name combobox

    Here is the same code for VSTA (C#):


    //...
    public partial class ThisProject
    {
       //WinAPI imports
       [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
               static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
    
       [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
               static extern int GetWindowTextLength(IntPtr hWnd);
    
    
       //public declarations
       zenOn.IDynPictures zPics;
    
       //initialization
       void ThisProject_Active()
       {
          zPics = this.DynPictures();
          zPics.ElementLeftButtonUp += new    zenOn.ElementLeftButtonUpEventHandler(zPics_ElementLeftButtonUp);
       }
    
       //ButtonUp Eventhandler
       void zPics_ElementLeftButtonUp(zenOn.IDynPicture obDynPicture, zenOn.IElement obElement, int lPosX, int lPosY, int lButton)
       {
          //Only on click on specific element
          if (obElement.Name == "TestButton")
          {
             IntPtr _hwnd;
             _hwnd = IntPtr.Zero;
             _hwnd = new IntPtr(obElement.Parent.Item("ComboboxName").hWnd);
             MessageBox.Show(GetText(_hwnd));
          }           
       }
    
       //Helper function to get the text
       public static string GetText(IntPtr hWnd)
       {
           //Allocate correct string length first
           int length = GetWindowTextLength(hWnd);
           StringBuilder sb = new StringBuilder(length + 1);
           GetWindowText(hWnd, sb, sb.Capacity);
           return sb.ToString();
       }
    /...
    Last edited by bernhardf : 24th February 2014 at 14:37

Similar Threads

  1. Recipe Group Manager (RGM)
    By robertf in forum VBA
    Replies: 2
    Last Post: 2nd March 2010, 16:21

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •