본문 바로가기
PowerBuilder

파워빌더 함수 - 2 (E ~ G)

by 엔터티 2021. 6. 8.
반응형

목차

     

    파워빌더 함수 - 1 (A~D)

    Arc( ) 주어진 좌표를 이용하여 아크를 그린다. Global External Function: FUNCTION boolean Arc(ulong hwnd, long r1, long r2, long r3, long r4, long a1, long a2, long a3, long a4) LIBRARY "Gdi32.dll" Sc..

    www.entity.co.kr

     

    Ellipse( )

    이 함수는 원에 기반을 둔 타원을 그린다. 

    Global External Function:
    FUNCTION boolean Ellipse(ulong hwnd,long x1,long y1,long x2,long y2) LIBRARY "Gdi32.dll"
    
    Script:
    Boolean rtn
    ulong l_handle, l_device
    long lv[4]
    
    l_handle = handle(w_main)
    l_device = GetDC(l_handle)
    lv[ ] = {5,5,300,300}
    rtn = Ellipse(l_device, lv[1], lv[2], lv[3], lv[4])



     

    ExitWindowsEx( )

    이 함수는 윈도우 O/S에게 윈도우가 종료되어야 함을 알려 윈도우 O/S가 종료되게 한다. 

    Global External Function:
    FUNCTION boolean ExitWindowsEx(uint dwReserved, uint uReserved) LIBRARY "User32.dll"
    
    Script:
    boolean rtn
    rtn = ExitWindowsEx(0,0)  // Zero's tell it to shut down immediately.



     

    FatalExit( )

    이 함수는 실행중인 에플리케이션을 강제로 종료시킵니다. 디버깅의 용도로는 사용하되 다른 용도로는 사용하지 않는 것이 좋다. 

    Global External Function:
    SUBROUTINE FatalExit(int exitcode) LIBRARY "Kernel32.dll"
    
    Script:
    int rtn
    
    rtn = MessageBox("This API call is suppose to produce a GPF!","Are You Sure?", Exclamation!, YesNo!,2)
    If rtn = 1 Then
        MessageBox("Final Notice!","You will have to reboot after this API call!")
        FatalExit(1)
    End If

     

     

    FindWindowA( )

    이 함수는 이름으로 호출된 윈도우의 핸들을 리턴합니다. 파워빌더 윈도우즈에서만 사용가능합니다. 파워빌더의 Handle( )과 유사합니다. 

    Global External Function:
    FUNCTION ulong FindWindowA(ulong classname,string windowname) LIBRARY "User32.dll"
    
    Script:
    ulong l_handle
    l_handle = FindWindowA(0,"<window name>") // i.e. "File Manager" or "Numbers.txt - NotePad"



     

    FreeLibrary( )

    이 함수는 활성 메모리에서 dll release시킵니다. 이 함수는 LoadLibraryA( )와 결합되어 사용됩니다. 

    Global External Function:
    SUBROUTINE FreeLibrary(ulong libhandle) LIBRARY "Kernel32.dll"
    
    Script:
    ulong modhandle  // This would usually be an instance variable
    
    modhandle = LoadLibraryA("<32 bit dll filename>")  // This would usually be done in another event.
    FreeLibrary(modhandle)



     

    GetBkColor( )

    이 함수는 윈도우의 백그라운트 칼라를 reference number에 의해 return합니다. 파워빌더의 다음 스크립트와 유사합니다

    ulong l_color
    l_color = w_main.BackColor 
    
    
    Global External Function:
    FUNCTION ulong GetBkColor (ulong hwnd) LIBRARY "Gdi32.dll"
    
    Script:
    ulong l_handle, l_device, l_color
    
    l_handle = handle(w_main)
    l_device = GetDC(l_handle)
    l_color = GetBkColor(l_device)

     

    GetCapture( )

    마우스에 의해 캡쳐된 윈도우의 핸들을 리턴합니다. 이때 윈도우는 마우스 커서가 어디에 있는가는 상관하지 않습니다. 

    Global External Function:
    FUNCTION ulong GetCapture( ) LIBRARY "User32.dll"
    
    Script:
    ulong l_handle
    
    l_handle = GetCapture( )



     

    GetComputerNameA( )

    이 함수는 컴퓨터의 이름을 참조의 방법으로 return합니다. 충분한 버퍼를 확보해야 합니다. 

    Global External Function:
    FUNCTION boolean GetComputerNameA(ref string cname,ref long nbuf) LIBRARY "Kernel32.dll"
    
    Script:
    string ls_compname
    long ll_buf
    
    ll_buf = 25
    ls_compname = space(ll_buf)
    GetComputerNameA(ls_compname, ll_buf)
    MessageBox("Computer name is:", ls_compname)



     

    GetClassNameA( )

    이 함수는 어떤 오브젝트나 윈도우의 핸들을 이용하여 클래스명을 리턴합니다. 충분한 버퍼를 확보해야 합니다. 

    Global External Function:
    Function long GetClassNameA(ulong hwnd, ref string cname, int buf) Library "User32.dll"
    
    Script:
    string l_class
    long rtn
    ulong l_handle
    
    l_handle = handle(w_main)
    l_class = space(50)
    rtn = GetClassNameA(l_handle,l_class,50)
    Messagebox("Classname", l_class)



     

    GetCurrentDirectoryA( )

    이 함수는 현재 작업디렉토리를 return합니다. 디렉토리 명이 다 들어갈만한 충분한 크기의 버퍼를 확보해야 합니다. 

    Global External Function:
    FUNCTION ulong GetCurrentDirectoryA(ulong BufferLen, ref string currentdir) LIBRARY "Kernel32.dll"
    
    Script:
    string ls_curdir
    ulong l_buf
    
    l_buf = 100
    ls_curdir = space(l_buf)
    GetCurrentDirectoryA(l_buf, ls_curdir)
    MessageBox("Current Directory:", ls_curdir)



     

    GetCurrentThread( )

    이 함수는 현재 thread handle return합니다. 

    Global External Function:
    FUNCTION ulong GetCurrentThread() LIBRARY "Kernel32.dll"
    
    Script:
    ulong rtn
    
    rtn = GetCurrentThread()
    MessageBox("Current Thread Handle", string(rtn))



     

    GetCursor( )

    이 함수는 커서의 핸들을 return합니다. 

    Global External Function:
    FUNCTION ulong GetCursor( ) LIBRARY "User32.dll"
    
    Script:
    ulong l_cursor
    l_cursor = GetCursor( )



     

    GetCursorPos( ) & SetCursorPos( )

    GetCursorPos() structure Mousepos를 이용해서 마우스의 x, y좌표를 return합니다. SetCursorPos()는 주어진 좌표로 마우스 커서를 이동시킵니다. 

    Global External Function:
    FUNCTION boolean GetCursorPos(ref mousepos mousepos2) LIBRARY "User32.dll"
    FUNCTION boolean SetCursorPos(int cx, int cy) LIBRARY  "User32.dll"
    
    Structure:  (Mousepos)
    long xpos, long ypos
    
    Script:
    mousepos mouseloc
    GetCursorPos(mouseloc)
    Messagebox("Cursor Position", "X = " + string(mouseloc.xpos) + "  Y = " + string(mouseloc.ypos))
    SetCursorPos(300,350)
    Messagebox("Cursor Position", "X = " + string(mouseloc.xpos) + "  Y = " + string(mouseloc.ypos))



     

    GetDC( )

    이 함수는 주어진 윈도우 핸들의 device context return합니다. device context는 어떤 그래픽함수를 호출하고자 할 경우에 필요합니다. 파워빌더에는 비숫한 함수가 없습니다. 

    Global External Function:
    Function ulong GetDC(ulong hwnd) library "user32.dll"
    
    Script:
    ulong l_handle, l_device
    
    l_handle = handle(w_main)
    l_device = GetDC(l_handle)
    MessageBox("Handle", string(l_device))



     

    GetKeyboardState( ) & SetKeyboardState( )

    첫번째 함수는 키보드의 모든 키의 상태를 256개의 ASCII배열에 의해서 return합니다. 두번째 함수는 주어진 배열의 상태에 따라서 키보드 상태를 set합니다. 여기에서 0은 키보드가 눌러지지 않는 것을 의미하고 그렇지 않은 값은 키보드가 눌러진 것을 의미합니다. 

    Global External Function:
    FUNCTION boolean GetKeyboardState(ref integer kbarray[256])  LIBRARY "USER32.DLL"
    FUNCTION boolean SetKeyboardState(ref integer kbarray[256]) LIBRARY "USER32.DLL"
    
    Script:
    //GetKeyboardState( )
    boolean rtn
    integer ipkey[256]
    
    rtn = GetKeyboardState(ref ipkey)
    
    //SetKeyboardState( )
    rtn = SetKeyboardState(ref ipkey)
    if rtn = false then
      Messagebox("Failed","Something went wrong when loading into array")
    else
      Messagebox("Successful","Keyboard state is loaded back into buffer")
    end if



     

    GetKeyState( )

    이 함수는 현재 키보드의 특정한 키의 상태를 ASCII값으로 참조하여 return합니다. 

    Global External Function:
    Function int GetKeyState(integer VirtualKeycode) Library "User32.dll"
    
    Script:
    int rtn
    
    rtn = GetKeyState(65)  // 65 = A
    if rtn = 0 then
      MessageBox("Key State","Letter 'A' not pressed!")
    else
      MessageBox("Key State","Letter 'A'  is pressed!")
    end if



     

    GetModuleHandleA( )

    이 함수는 활성 메모리의 모듈이나 dll의 핸들을 return합니다. 

    Global External Function:
    Function long GetModuleHandleA(string modname) Library "Kernel32.dll"
    
    Script:
    ulong rtn
    
    rtn = GetModuleHandleA("User32.dll")
    MessageBox("Return Code", string(rtn))



     

    GetParent( )

    이 함수는 child handle을 검색하여 parent handle return합니다. 파워빌더의 'GetParent()'가 이 함수와 동일합니다. 

    Global External Function:
    FUNCTION ulong GetParent(ulong hwnd) LIBRARY "User32.dll"
    
    Script:
    ulong l_handle, rtn
    
    l_handle = handle(cb_getparent) // Command Button name
    rtn = GetParent(l_handle)
    Messagebox("GetParent", "Parent handle = " + string(rtn) + " / Child handle = " + string(l_handle))

     

     

    GetPixel( ) & SetPixel( )

    첫번째 함수는 특정한 픽셀의 색을 알려주며 두번째 함수는 특정한 좌표의 색을 변경합니다. 

    Global External Function:
    FUNCTION ulong GetPixel(ulong hwnd, long xpos, long ypos) LIBRARY "Gdi32.dll"
    FUNCTION ulong SetPixel(ulong hwnd, long xpos, long ypos, ulong pcol) LIBRARY "Gdi32.dll"
    
    Script:
    long lx, ly
    ulong rtn
    ulong l_handle, l_device
    
    lx = 100
    ly = 100
    l_handle = handle(w_main)
    l_device = GetDC(l_handle)
    rtn = GetPixel(l_device, 100, 100)
    MessageBox("Position " + string(lx) + "," + string(ly),"Color = " + string(rtn))
    SetPixel(l_device, lx, ly, 0)  // This call will set the pixel at lx, ly to black.



     

    GetSystemMetrics( )

    이 함수는 현재 화면의 해상도 픽셀단위를 이용해서 알려줍니다. 이 함수는 아주 민감하여 정확히 선언을 해야 하며 "GetSystemMetrics"라고 선언해야 하는데 "getsystemmetrics"로 선언하면 절대 안됩니다. 

    Global External Function:
    FUNCTION int GetSystemMetrics(int indexnum) LIBRARY "user32.dll"
    
    Script:
    int l_xx, l_yy
    
    l_xx = GetSystemMetrics(0)
    l_yy = GetSystemMetrics(1)
    Messagebox("Screen Resolution", string(l_xx) + " , " + string(l_yy))



     

    GetSystemMenu( )

    이 함수는 에플리케인션이 복사 또는 수정을 위해 시스템이나 윈도우즈의 메뉴를 사용할 수 있게 합니다. 

    Global External Function:
    FUNCTION boolean GetSystemMenu(ulong mhandle, boolean flag) LIBRARY "user32.dll"
    
    Script:
    boolean flag
    ulong l_handle, m_handle
    
    l_handle = handle(w_main)
    flag = false
    m_handle = GetSystemMenu(l_handle, flag)
    Messagebox("Return Code", string(m_handle))



     

    GetSystemTime( )

    이 함수는 structure SystemTime을 이용하여 시스템 타임을 return합니다. 

    Global External Function:
    SUBROUTINE GetSystemTime(ref systemtime systimeptr) Library "Kernel32.dll"
    
    Structure:  (SystemTime)
    uint year,  uint month,  uint dayofweek,  uint day,  uint hour,  uint minute,  uint second,  uint millisecond
    
    Script:
    systemtime s_systime
    string l_day, l_date, l_time
    
    GetSystemTime(s_systime)
    
    l_date = string(s_systime.month) +"/"+ string(s_systime.day) &
           +"/"+ string(s_systime.year)
    l_time = string(s_systime.hour) +":"+ string(s_systime.minute) &
           +":"+ string(s_systime.second) +":"+ string(s_systime.millisecond)
    
    CHOOSE CASE s_systime.dayofweek
       CASE 1
          l_day = "Sunday"
       CASE 2
          l_day = "Monday"
       CASE 3
          l_day = "Tuesday"
       CASE 4
          l_day = "Wednesday"
       CASE 5
          l_day = "Thursday"
       CASE 6
          l_day = "Friday"
       CASE 7
          l_day = "Saturday"
    END CHOOSE
    Messagebox("System Time:",l_date + "   " + l_day + "   " + l_time)



     

    GetThreadPriority( )

    이 함수는 주어진 thread의 우선 순위를 return합니다. 

    Global External Function:
    FUNCTION int GetThreadPriority(ulong hthread) LIBRARY "Kernel32.dll"
    
    Script:
    ulong l_handle
    integer rtn
    
    l_handle = GetCurrentThread()
    rtn = GetThreadPriority(l_handle)
    MessageBox("Current Thread Priority", string(rtn))



     

    GetUserNameA( )

    이 함수는 현재 유저의 로그온 네임을 return합니다. (유저명을 저장할 수 있을 만큼의 충분한 버퍼를 확보해야 합니다.) 

    Global External Function:
    FUNCTION boolean GetUserNameA(ref string uname, ref ulong slength) LIBRARY "ADVAPI32.DLL"
    
    Script:
    string  ls_username
    string  ls_var
    ulong  lu_val
    boolean rtn
    
    lu_val = 255
    ls_username = Space( 255 )
    rtn = GetUserNameA(ls_username, lu_val)
    Messagebox("GetUserNameA", "Username = " + string(ls_username))



     

    GetWindowsDirectoryA( )

    이 함수는 윈도우즈 디렉토리를 return하며 디렉토리를 얻기 위해 디렉토리가 저장될 만한 길이의 충분한 메모리를 확보해야 합니다. 

    Global External Function:
    FUNCTION ulong GetWindowsDirectoryA(ref string wdir, ulong buf) LIBRARY "kernel32.dll"
    
    Script:
    ulong l_buf
    string windir
    
    l_buf = 144
    windir = space(144)
    GetWindowsDirectoryA(windir, l_buf)
    MessageBox("Current Directory", windir)



     

    GlobalMemoryStatus( )

    이 함수는 structure Memory를 이용하여 현재 메모리의 모든 정보를 리턴합니다. 

    Global External Function:
    
    SUBROUTINE GlobalMemoryStatus(ref memory mem2) LIBRARY "Kernel32.dll"
    
    Structure:(Memory)
    ulong m_length, ulong m_loaded, ulong m_totalphys, ulong m_availphys, &
    ulong m_totalpagefile, ulong m_availpagefile, ulong m_totalvirtual, &
    ulong m_availvirtual
    
    Script:
    memory sysmem
    
    GlobalMemoryStatus(sysmem)
    Messagebox("Memory Length", string(sysmem.m_length))
    Messagebox("Memory Loaded", string(sysmem.m_loaded))
    Messagebox("Total Physical Memory", string(sysmem.m_totalphys))
    Messagebox("Total Available Memory", string(sysmem.m_availphys))
    Messagebox("Total Page Size", string(sysmem.m_totalpagefile))
    Messagebox("Available Page Size", string(sysmem.m_availpagefile))
    Messagebox("Total Virtual Memory", string(sysmem.m_totalvirtual))
    Messagebox("Available Virtual Memory", string(sysmem.m_availvirtual))

     

     

     

    파워빌더 함수 - 3 (L ~ P)

    LoadLibraryA( ) 이 함수는 dll을 (활성)메모리에 로드합니다. 32비트에서만 사용할 수 있습니다. Global External Function: FUNCTION ulong LoadLibraryA(string modname) LIBRARY "Kernel32.dll" Script: ulong..

    www.entity.co.kr

     

     

    파워빌더 함수 - 4 (R ~ W)

    파워빌더 함수 - 1 (A~D) Arc( ) 주어진 좌표를 이용하여 아크를 그린다. Global External Function: FUNCTION boolean Arc(ulong hwnd, long r1, long r2, long r3, long r4, long a1, long a2, long a3, long a4..

    www.entity.co.kr

     

    반응형

    댓글