You're not adding anything anywhere, nor are you ever changing selectedItemID, which wouldn't really make much sense anyway, because it is a function parameter (at least at the place you seem to have copy pasted the code from) and its value will be gone once the function returns. The selectedItemID is given to your plugin by the client when your menu was clicked, so you can know which user / channel the user used your plugin on.
The value of firstID is lost when it goes out of scope, which is either when the function exits or when the client unloads your plugin, depending on where you defined it.
As for creating a window, that can be done using Qt for example.
When sending PMs please make sure to include a reference link to the thread in question in the body of your message.