Announcement

Collapse
No announcement yet.

A receipt for question: "Save changes to ...?"

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guest's Avatar
    Guest replied
    Lance --

    Hello!
    SUCCEED!!! YES!!!
    My simple sample:
    '-------------------------------------------------------
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"

    GLOBAL sWindowTitle AS STRING
    GLOBAL hTargetWindow AS LONG
    GLOBAL sMsgboxTitle AS STRING
    GLOBAL hMsgboxWindow AS LONG
    GLOBAL hButtonYes AS LONG

    FUNCTION PBMAIN
    'Running:
    '"C:\MSOffice\Office\WINWORD.EXE C:\TEMP\OPEN_CLOSE.DOC"
    letsgo$="C:\MSOffice\Office\WINWORD.EXE C:\TEMP\OPEN_CLOSE.DOC"
    go& = SHELL(letsgo$,3)

    SLEEP 10000 ''...10 sec time for change | simulate change...

    '...close application
    sWindowTitle = "Microsoft Word - Open_Close.doc"
    hTargetWindow = FindWindow("", BYVAL STRPTR(sWindowTitle))
    PostMessage hTargetWindow, %WM_CLOSE, 0, 0
    PostMessage hTargetWindow, %WM_QUIT, 0, 0

    '...dialog "Save changes to ...?" <Yes/No/Cancel>
    '... YES!
    sMsgboxTitle = "Microsoft Word"
    hMsgboxWindow = FindWindow("", BYVAL STRPTR(sMsgboxTitle))
    hButtonYes=GetDlgItem(hMsgboxWindow, %IDYES)
    SendMessage hButtonYes, %BM_CLICK, 0, 0

    END FUNCTION
    '---------------------------------------------------------

    Thanks for your hint!
    Alexander


    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Lance --

    Thank for your hint, but my prog-a work without success.
    Can you help me?
    This is source:
    '=======================
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"

    GLOBAL sWindowTitle AS STRING
    GLOBAL hTargetWindow AS LONG
    GLOBAL hButtonYes AS LONG

    FUNCTION PBMAIN
    'Running:
    '"C:\MSOffice\Office\WINWORD.EXE C:\TEMP\OPEN_CLOSE.DOC"

    sWindowTitle = "Microsoft Word - Open_Close.doc"
    hTargetWindow = FindWindow("", BYVAL STRPTR(sWindowTitle))

    SendMessage hTargetWindow, %WM_CLOSE, 0, 0
    SendMessage hTargetWindow, %WM_DESTROY, 0, 0
    'WM_DESTROY for save original windows size by close!!!

    '...dialog "Save changes to ...?" <Yes/No/Cancel>
    '...sWindowTitle = "Microsoft Word"
    '...hTargetWindow = FindWindow("", BYVAL STRPTR(sWindowTitle))
    EnumChildWindows hTargetWindow , hButtonYes, %IDYES
    ' The EnumChildWindows function - fail !??
    ' where is mistake?
    SendMessage hButtonYes, %BM_CLICK, 0, 0 'without success

    END FUNCTION
    '====================

    Thanks
    Alexander


    ------------------

    Leave a comment:


  • Michael Mattias
    replied
    I don't suppose you have the source code to WORD or EXCEL lying around do you Michael?
    I didn't read the question that way. I thought we wanted to know "How to do this, "like" Word(r) or Excel(r) do it.

    Or maybe it's the combimation of too many birthdays and the fact that my vacation is now scheduled.

    MCM

    Leave a comment:


  • Semen Matusovski
    replied
    Alexander --
    To do this in VB is very easy
    Dim Word As Object
    Set Word = CreateObject("Word.Application")
    ...
    Word.Quit wdDoNotSaveChanges
    Set Word = Nothing

    But how do you work with such objects in PB ?



    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    I don't suppose you have the source code to WORD or EXCEL lying around do you Michael?


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected]support[email protected]</A>

    Leave a comment:


  • Michael Mattias
    replied
    Lance already cautioned ou about trying to send multiple messages with the OR operator...

    As far as your underlying question goes, what you need to do is process the WM_CLOSE message inside the target window.

    FUNCTION WindowProcOfTargetWindow (..params..)

    STATIC SaveNeeded AS LONG

    SELECT CASE WMsg

    ....
    CASE %WM_CLOSE
    IF SaveNeeded THEN
    SaveMe = MSGBOX("Save current file?" ...options)
    IF SaveMe= %IDYES...


    Etc etc

    MCM

    Leave a comment:


  • Lance Edmonds
    replied
    First, you _cannot_ ever combine messages as you have done (%WM_CLOSE OR %WM_NCDESTROY)... you must send such messages separately!

    However, there is no reason at all to send a %WM_NCDESTROY message (this message should originate from Windows itself, not your code!), so just %WM_CLOSE should be adequate.

    To close the dialog that pop's up, you could try sending a %BM_CLICK message to the OK or NO button - to get the the handles to the buttons on the dialog, you could try using EnumChildWindows() - I think it works across process boundaries.




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Guest's Avatar
    Guest started a topic A receipt for question: "Save changes to ...?"

    A receipt for question: "Save changes to ...?"

    Hello!
    I try windows Program (e.g. Excel, Word...) close:
    ...
    SendMessage hTargetWindow, %WM_CLOSE OR %WM_NCDESTROY, 0, 0
    ...
    and get: "Save changes to ...?" <Yes/No/Cancel>

    How can AUTOsave to... + CLOSE? without program
    message "Save changes to ...?" <Yes/No/Cancel> ???
    I like the change (doc, xls,...) save. (

    Thanks
    Alexander
Working...
X