Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom AP payment losing default check stock\open custom screens not detectected when closing accpac

Status
Not open for further replies.

LESHEL

Programmer
Jan 11, 2012
11
US
We have a custom ui for the ap payment process. When they go to print a check they have to change the check stock from payroll to ap if a payroll check has been printed prior to printing in ap. The reverse now happens in payroll (which we didn't change). If they print a check from ap prior to a payroll check the default check stock is now defaulted to ap. We didn't change the check form itself. We put our code in the onrecordchanging event of the payment entry screen. Also, if we leave our custom screen open and close accpac our screen stays open. How do we get it to work like the original screens and have accpac detect that there is a screen open? Sorry, obviously I am a novice when it comes to ACCPAC programming. Thanks so much for your help!
 
Assumptions are that you created a project and dumped the Accpac OCX onto a form and then created an EXE?
Do you include accpac session login information in your code or do you attach to an existing Accpac session?
 
Code:
Public Const WM_GETICON = &H7F
Public Const WM_SETICON = &H80

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function IsIcconic Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long

'Constants used for the return of the MultiInst function
Public Const OPEN_APPLICATION = 0
Public Const SINGLE_INSTANCE_OPEN = 1




Private Sub AccpacOE1100UICtrl_OnUIAppOpened()
Dim hWnd As Long
Dim hIcon As Long
Dim MultiInstResult As Integer
Dim iWindow As Integer

'On Error Resume Next

With Me.AccpacOE1100UICtrl
    Set Me.Icon = .UIIcon
    hIcon = SendMessage(Me.hWnd, WM_GETICON, ICON_BIG, ByVal 0)
    SendMessage nMainhWnd, WM_SETICON, ICON_BIG, ByVal hIcon
    sCompanyID = .UIDBLinks(1).Session.CompanyID
    
    
    'Call procedure to determine if an instance of the application is already loaded
    MultiInstResult = MultiInst(sCompanyID & " - O/E Order Entry")
    
    If MultiInstResult = SINGLE_INSTANCE_OPEN Then
       'An instance already exists cancel the current application load
        End
    End If
end sub

Public Function MultiInst(sWindow As String) As Integer
'This function determines if a single instance of the
'application is already running.

Dim hwndFound As Long   'The window handle
Dim strWindowName       'The Caption on the window

'Set the caption of the application form
strWindowName = sWindow

'Get the handle of the application if it is open
hwndFound = FindWindow(vbNullString, strWindowName)

If hwndFound Then
     'Set the function return
     MultiInst = SINGLE_INSTANCE_OPEN

     'If application minimized, restore, show it on top
     If IsIcconic(hwndFound) Then
          ShowWindow hwndFound, SW_RESTORE
          'Show the window infront of all other windows
          SetForegroundWindow hwndFound
     Else
          'Bring the application top most on the screen
          SetForegroundWindow hwndFound
    End If
ElseIf hwndFound = 0 Then
    'Set the function return so it will continue loading
    MultiInst = OPEN_APPLICATION
End If
End Function
 
Yes ettienne. I did put the ocx on my form. I am just attaching to the existing session.
 
What happens when you run your EXE from Windows Explorer with Accpac closed?
 
Thank you tuba2007. I did get your code to work and now we only allow one instance of the page to be loaded. The problem is that if that screen is up and we exit out of accpac, my window stays up. Normally accpac checks to see if all windows are closed but it doesn't check for my custom form. What am I missing?
 
You have a stand alone app that happens to load an Accpac form, Accpac itself is not aware of your app and therefor does not care if it is running or not.
 
ettienne, I get the same results whether I am loggin in to accpac or just running the program from explorer, of course I have to log in to a new session if I run it from scratch from explorer.

tuba2007, I do have the sdk. Just very green when it comes to using it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top