How can I expand ComboBox via application

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

How can I expand ComboBox via application

Post by mol »

Do anybody know the way to expand ComboBox?
I need to set focus and expand this control automatically...
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: How can I expand ComboBox via application

Post by serge_girard »

Hi Marek,

What do you mean with expand? Add Items or enlarge combobox?

Serge
There's nothing you can do that can't be done...
User avatar
dragancesu
Posts: 921
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: How can I expand ComboBox via application

Post by dragancesu »

I think the program should open a combox when it comes to this field,
Probably ON GOTFOCUS , but I do not know how to get control to open the list,
Control requires a click or cursor action
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: How can I expand ComboBox via application

Post by Rathinagiri »

Yes. It can be done!

Consider this...

Code: Select all


   define combobox usernames
      row 10
      col 160
      width 330
      sort .t.
      fontsize nFontSize
      fontname cFontName
      fontbold lFontBold
      ongotfocus comboboxdropdown()
      items aUsers
   end combobox
//
//

//

function comboboxdropdown
    local nHandle := GetControlHandle (this.name,thiswindow.name)
    ComboBoxShowDropDown(nHandle)
return nil

function comboboxdropdownclose( cWindowName, cControlName )
    local nHandle
    default cWindowName := this.name
    default cControlName := thiswindow.name
    nHandle := GetControlHandle ( cControlName , cWindowName )
    ComboBoxShowDropDownClose( nHandle )
return nil

   
function ensuretopindex
    local nHandle := GetControlHandle (this.name,thiswindow.name)
    if this.value > 0
       ComboBoxSetTopIndex(nHandle,this.value)
    endif   
    return nil




 #pragma BEGINDUMP

 #include <windows.h>
 #include <commctrl.h>
 #include "hbapi.h"
 #include <wingdi.h>

 HB_FUNC ( COMBOBOXSHOWDROPDOWN )

 {
    HWND hWnd1;
    hWnd1 = (HWND) hb_parnl (1);
    SendMessage((HWND) hWnd1,CB_SHOWDROPDOWN,    (WPARAM)(int) 1,(LPARAM)(int) 0);
 }

 HB_FUNC ( COMBOBOXSHOWDROPDOWNCLOSE )

 {
    HWND hWnd1;
    hWnd1 = (HWND) hb_parnl (1);
    SendMessage((HWND) hWnd1,CB_SHOWDROPDOWN,    (WPARAM)(int) 0,(LPARAM)(int) 0);
 }
 
 HB_FUNC ( COMBOBOXSETTOPINDEX )
 {
    HWND hWnd1;
    hWnd1 = (HWND) hb_parnl (1);
    hb_retni(SendMessage((HWND) hWnd1,CB_SETTOPINDEX, (WPARAM)(int) hb_parni(2) - 1,(LPARAM) 0 ));
 }


 #pragma ENDDUMP   

East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
Post Reply