View Full Version : How to get the page name?
ronwilliams
02-25-2010, 03:10 AM
How can I obtain the name of a page in AMS?
infinityscape
02-25-2010, 03:54 AM
Hey, not sure if this works, as i have wrote it of the top of my head but something like this might work:
EXAMPLE DOESNT WORK, SORRY
also you might want to get the autoit or winapi plugin to do this as im pretty sure they have the very function you need
Autoit Plugin (http://amsplugins.com/details.asp?ID=113&CID=1)
WinApi Plugin (http://amsplugins.com/details.asp?ID=17&CID=1)
ronwilliams
02-25-2010, 04:06 AM
it gives an error arg 2 must be of type string?
RizlaUK
02-25-2010, 04:09 AM
mmm, you missed the obvious there, for loops and plugins, WTH are you doing!!
@ron, try this :yes
-- clear all focus objects
Page.SetFocus("");
-- now get the page name
local sPage = Page.GetFocus();
Dialog.Message("Notice", "The name of the page you are viewing is: "..sPage );
EDIT:
and for a DialogEx, change Page to DialogEx
-- clear all focus objects
DialogEx.SetFocus("");
-- now get the page name
local sDialog = DialogEx.GetFocus();
Dialog.Message("Notice", "The name of the dialog you are viewing is: "..sDialog);
infinityscape
02-25-2010, 04:13 AM
ok, sorry rizla for trying :wow but he is right as always, i was simply trying to help, i dont have ams with me at the moment so i didnt think about that, thanks RizlaUK
ronwilliams
02-25-2010, 04:16 AM
RIZLA, once again, you are da man!
works perfectly!
Thanks to both of you!
RizlaUK
02-25-2010, 04:34 AM
@infinityscape, when i started with AMS i was always doing the same, pure overkill for a simple task, i dident learn by not being told about my mistakes
and remember, when posting code you automatically paint yourself as a target, people can either shoot that target with a complement or a criticism, would you rather i lied and said "great work" when you completely mess up, or would you rather be told what you've done wrong so you learn something for next time
dont take it to heart man, i do it to everyone, im not being mean, im trying to help (even tho i said i wouldent anymore,,,,,just cant help myself)
@ron, np, glad to help
longedge
02-25-2010, 06:33 AM
and remember, when posting code you automatically paint yourself as a target, people can either shoot that target with a complement or a criticism, would you rather i lied and said "great work" when you completely mess up, or would you rather be told what you've done wrong so you learn something for next time
Can't remember how many times I've answered pm's to say I only post to the forum. That way if I make a mistake or misinterpret a question, then someone will correct me thank goodness :).
T3STY
02-25-2010, 12:12 PM
-- clear all focus objects
Page.SetFocus("");
-- now get the page name
local sPage = Page.GetFocus();
Dialog.Message("Notice", "The name of the page you are viewing is: "..sPage );
Now, I'm gonna say WTH! Didn't anyone knew this function?
result = Application.GetCurrentPage();
p.s. Sorry, I didn't said that with aggressive intentions, even if it looks like.
Centauri Soldier
02-26-2010, 02:09 PM
Here's a method for getting the name of the current page or dialog without having to know which it is. I built this a while ago on a project that had a lot of pages and dialogs.
Put this in your Globals.
--=========================
-- GetCurrentPageOrDialog
--=========================
function GetCurrentPageOrDialog()
local sType = "";
local sCurrent = "";
if Application.GetCurrentDialog() ~= "" then
sCurrent = Application.GetCurrentDialog();
sType = "dialog";
return sCurrent, sType
else
sCurrent = Application.GetCurrentPage();
sType = "page";
return sCurrent, sType
end
--return the current page/dialog name [string] as the first variable and the type (page or dialog) as the second variable [string]
end
Example Usage
Put this on the OnShow event of a page and/or dialog.
local sName, sType = GetCurrentPageOrDialog();
Dialog.Message(sType, sName);
and put that in your pipe and smoke it. :D
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.