How can I expand ComboBox via application

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
mol
Posts: 3062
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 176 times
Been thanked: 96 times
Contact:

How can I expand ComboBox via application

Post by mol » Thu Oct 18, 2018 7:39 pm

Do anybody know the way to expand ComboBox?
I need to set focus and expand this control automatically...

User avatar
serge_girard
Posts: 2139
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 449 times
Been thanked: 102 times
Contact:

Post by serge_girard » Thu Oct 18, 2018 8:21 pm

Hi Marek,

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

Serge

User avatar
dragancesu
Posts: 574
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 14 times
Been thanked: 111 times

Post by dragancesu » Fri Oct 19, 2018 6:22 am

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: 5246
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 165 times
Been thanked: 164 times
Contact:

Post by Rathinagiri » Fri Oct 19, 2018 6:33 am

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.

User avatar
mol
Posts: 3062
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 176 times
Been thanked: 96 times
Contact:

Post by mol » Fri Oct 19, 2018 12:06 pm

Thank you! It works perfectly as I mentioned :D

Post Reply