Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Calling a function in another window.

Calling a function in another window.

Scheduled Pinned Locked Moved C#
data-structureshelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bojan Rajkovic
    wrote on last edited by
    #1

    I'm writing an MP3 player, with queueing capabilities - it writes the queue to a temporary text file, and I also have another form in the app that allows me to view the queue. This works fine, but I can't refresh the queue automatically. I would like to be able to just call the writeQ function in the main form to write the queue, then call the queue viewer forms' load function which would read the necessary data. But, my problem is, I don't understand how I can get the handle of the main form to call the writeQ. simply doing a MainPlayer mainP = new MainPlayer() then calling mainP.writeQ() (MainPlayer is the main form class) won't work, because it'll try to read the listBox in the queue viewer form...Anyone know how I could force it to read the listBox in its own form? I would think I can do it using IntPtr and window handles, but I have no idea quite how to do this.

    D 1 Reply Last reply
    0
    • B Bojan Rajkovic

      I'm writing an MP3 player, with queueing capabilities - it writes the queue to a temporary text file, and I also have another form in the app that allows me to view the queue. This works fine, but I can't refresh the queue automatically. I would like to be able to just call the writeQ function in the main form to write the queue, then call the queue viewer forms' load function which would read the necessary data. But, my problem is, I don't understand how I can get the handle of the main form to call the writeQ. simply doing a MainPlayer mainP = new MainPlayer() then calling mainP.writeQ() (MainPlayer is the main form class) won't work, because it'll try to read the listBox in the queue viewer form...Anyone know how I could force it to read the listBox in its own form? I would think I can do it using IntPtr and window handles, but I have no idea quite how to do this.

      D Offline
      D Offline
      Dimitris Iliopoulos
      wrote on last edited by
      #2

      The thing you want to do, i think is done more easily in that way. Once the user want to change your playlist immediately you go and update the file you are writing. The other form will use a filesystemwatcher component so that once it sees that the file you want changed he will go and update the view of the playlist. If you want to do the thing you are saying you will have to mark the writeQ method as public and when you create the viewer form pass a variable of type MainPlayer with the mainform in it in the constructor and store this variable as a member and call the function writeQ in it. From Greece: Dimitris Iliopoulos dimilio@yahoo.com

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups