Messagebox on client side

Discussion in 'Ruby' started by Amit Tomar, Oct 20, 2010.

  1. Amit Tomar

    Amit Tomar Guest

    Hii all,
    I used win32 api messagebox in ruby to generate a messagebox
    but only server side am able to see is there any way to open it at
    client side??

    --
    Posted via http://www.ruby-forum.com/.
    Amit Tomar, Oct 20, 2010
    #1
    1. Advertising

  2. Amit Tomar

    Jeremy Bopp Guest

    On 10/20/2010 7:33 AM, Amit Tomar wrote:
    > Hii all,
    > I used win32 api messagebox in ruby to generate a messagebox
    > but only server side am able to see is there any way to open it at
    > client side??


    No, it is not possible. Your Ruby code is running on your server and
    therefore can only access the Win32 API on your server. It has no way
    to access the API on a client machine connecting to your server, and how
    would that work for a non-Windows client anyway?

    Do you need to use the Win32 API for this, or would a rough equivalent
    handled via javascript in the web browser of the client suffice?

    -Jeremy
    Jeremy Bopp, Oct 20, 2010
    #2
    1. Advertising

  3. Amit Tomar

    Amit Tomar Guest

    Thanks jermy for your response ,this is something i want to achive .In
    my application am uploading file to a folder but file is already there
    it would ask for overwrite by displaying messagebox but problem i
    already told .Could you suggest some other way to achieve this
    means i don;t know much about javascript .can we send desktop of one
    machine to other??

    require 'dl'
    # button
    constantsBUTTONS_OK = 0
    BUTTONS_OKCANCEL = 1
    BUTTONS_ABORTRETRYIGNORE = 2
    BUTTONS_YESNO = 4

    CLICKED_CANCEL = 2
    CLICKED_ABORT = 3
    CLICKED_RETRY = 4
    CLICKED_IGNORE = 5
    CLICKED_YES = 6
    CLICKED_NO = 7





    class UploadController < ApplicationController
    def index
    render :file => 'app\views\upload\uploadfile.rhtml'
    end


    def message_box(txt, title=APP_TITLE, buttons=BUTTONS_OK)
    user32 = DL.dlopen('user32')
    msgbox = user32['MessageBoxA', 'ILSSI']
    r, rs = msgbox.call(0, txt, title, buttons)
    return r
    end




    def uploadFile

    name=DataFile.save1(params[:upload])
    puts name
    $t=0

    k = []

    File.open("d:/dm/aan.txt").each do |line|
    k << line.chomp
    end

    puts k
    #puts line.size
    $s=k.size
    #puts $s



    for i in 0..Integer($s)

    if $L=(name.eql?(k) == true)

    response = message_box("Are you sure you want to OVERWRITE",
    "Proceed?", BUTTONS_YESNO)
    if response == CLICKED_YES



    post = DataFile.save(params[:upload])

    render :text => "File has been uploaded successfully"
    else

    render :text => "File cann't successfully"
    end
    end
    end
    end
    end

    --
    Posted via http://www.ruby-forum.com/.
    Amit Tomar, Oct 20, 2010
    #3
  4. Amit Tomar

    Jeremy Bopp Guest

    On 10/20/2010 8:50 AM, Amit Tomar wrote:
    > Thanks jermy for your response ,this is something i want to achive .In
    > my application am uploading file to a folder but file is already there
    > it would ask for overwrite by displaying messagebox but problem i
    > already told .Could you suggest some other way to achieve this
    > means i don;t know much about javascript .can we send desktop of one
    > machine to other??


    No, you cannot send the desktop, and you wouldn't want to either. I'll
    leave you to think of scary reasons you never want to do that.

    Your only option is to send a response to the user asking for
    confirmation in the event that the file exists. That response could
    simply be another page that has a couple buttons for Yes or No options.
    You would have to make the server store the uploaded file into some
    sort of temporary location in this case since the file will be uploaded
    from the first page. Once the user confirms to overwrite the file, the
    server could then move the file from the temporary location to the final
    one.

    That's all very rough, unfortunately. I don't have enough experience
    with web apps and Rails to help you with anything concrete. All I can
    say is that you have headed down the completely wrong path with using
    the Win32 API to handle this prompt to the user. It cannot be made to work.

    There are options available in javascript that will allow you to do
    something similar from within the client's browser, but I don't know the
    details of how to use those functions. Someone on the Rails list should
    be able to help you more.

    -Jeremy
    Jeremy Bopp, Oct 20, 2010
    #4
  5. Amit Tomar

    Amit Tomar Guest

    Amit Tomar, Oct 20, 2010
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yaya coco
    Replies:
    1
    Views:
    379
    Rajesh Tiwari
    Jul 4, 2003
  2. Boss302
    Replies:
    0
    Views:
    1,006
    Boss302
    Nov 21, 2006
  3. Bogdan
    Replies:
    2
    Views:
    630
    Bogdan
    Jun 9, 2008
  4. juan

    messagebox from server side

    juan, Sep 19, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    96
    Ravikanth[MVP]
    Sep 19, 2003
  5. Zoe Hart
    Replies:
    1
    Views:
    336
    Scott Wisniewski
    Jan 8, 2004
Loading...

Share This Page