How to use main menu handle in TrackPopupMenu() - winapi

I am recently reading the article of Petzold Charles's Programming Windows(5th Edition), in the book's p371, it mentioned you can display a popup menu by making use of the main menu(which you created like below:)
MENUDEMO MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New", IDM_FILE_NEW
END
POPUP "&Edit"
BEGIN
MENUITEM "&Undo", IDM_EDIT_UNDO
END
END
That the TrackPopupMenu requires a popup menu handle, and the handle acquired from above resource is not. But as the book said you can refer to MS Knowledge Base Q99806 to find the solution on how to walk around this.
I have tried to search that article but cannot find(It seems, over the years, Microsoft has moved many such articles). If anyone has a copy of it or knows the solution, would you please share it with me. Thank you for your help in advance.

hBar=LoadMenu;
hPop=GetSubMenu(hBar,0);
RemoveMenu(hBar,0,MF_BYPOSITION);
TrackPopupMenuEx(hPop,...);

Related

How to be notified when an edit box has been updated

In a VB6 project, I would like to be notified when an edit control (text field) has been updated (i.e. : character string has been added by a user into the text field).
I did not find any documentation on the different events which can be catched for an edit MFC control.
Thanks in advance.
Its the _Change event. However, I personally do not like this event since it is notoriously unreliable.
Private Sub txtYourTextFieldControl_Change()
' some code here
End Sub
* edit *
We are talking about VB6 textbox, correct? I am not sure what MFC has to do with this.

Access button in div popup watir web-driver

I am trying to retrieve, modify, and reinsert some text in a pop up dialog using watir web-driver. All was going swimmingly until I tried to find a way to click the "Save Book Info" button pictured here: http://i.stack.imgur.com/pGdln.png
However I am unable to find the button. To access the pop up box I gather all the links with the correct name into an array:
#browser.imgs.each do |img| #The links are imgs
if img.title.include?('Edit/Delete Book')
#books << img
end
end
From there I can access the links with #books[index].click. I am able to access and edit the text_fields with:
url = #browser.text_field(:name=>'url').value
... do stuff with url ..
#browser.text_field(:name=>'url').set url
But when I try and find the "Close" button I only get the buttons that are on the main page. After many headaches I managed to find the title of the window I want to work with using #browser.div(:class=>'dijitDialogTitleBar').title, which returns "Edit Book". Success! No. I still can't figure out how to access the buttons on that popup!
If anyone could help me with this I would be most grateful. This is my first time using Watir so it's probably a simple answer...
If more information is needed I'd be happy to supply it. Thanks in advance.
EDIT
Here is the html for the button:
<span id="dijit_form_Button_2_label"
class="dijitReset dijitInline dijitButtonText"
dojoattachpoint="containerNode">Save Book Info</span>
It looks like you have a span tag that is styled to be looked like a button. You need to access it is a span instead of a button.
Try:
#browser.span(:text => 'Save Book Info').click

How Do You Change the Title of a Page in wx.aui.AuiNotebook?

So I'm working on a text editor to better learn wxPython (and to make a text editor that I really like :P). I have been having trouble finding much info on the wx.aui.AuiNotebook class. One thing I would like to know is how to interact with its pages. For example, I would really like to know how to change the title of a page (so that I can update the page title when a user saves or to mark it when there is unsaved changes). Any assistance on this matter would be most appreciated!
The method is called SetPageText, so you would do something like:
current_page = notebook.GetCurrentPage()
current_page_index = notebook.GetPageIndex(current_page)
current_label = notebook.GetPageText(current_page_index)
if not current_label.endswith(' (*)':
notebook.SetPageText(current_page_index, current_label + ' (*)')
Apparently, in wxPython version 2.8 does not include wx.aui.AuiNotebook.GetCurrentPage(). What I apparently didn't realize is that a "page" in the wx.aui.AuiNotebook is equivalent to the panel that is being added to it. Thus the following code will work,
self.panelBox = []
newPanel = wx.Panel(self, wx.ID_ANY)
#YADA YADA STUFF!
self.nb.AddPage(newPanel, "Untitled Document "+str(self.untitledDocCount))
currPageIndex = self.nb.GetPageIndex(newPanel)
currLabel = self.nb.GetPageText(currPageIndex)
if not currLabel.endswith(' (*)'):
self.nb.SetPageText(currPageIndex, currLabel+' (*)')
self.panelBox.append(newPanel)
It's up to the programmer to ensure that the pages (panels) are accessible. I do this by storing the panel references in a "panel box" and then switching between them accordingly in conditions such as a "change tab" event. I don't know if this is the best way to do this, but it appears to work so far.

How do I refresh a "form element" when it is changed through a webbrowser control?

I am using VB6 (yes, I know it's 10 years old :), but it works). VB.NET answers may work as well, so if you know the answer, please answer too!
I am "manually" setting a dropdown box in a form, yet the 'webbrowser' doesn't seem to update.
Here's an example
If you notice in the form, it has a place where it asks you to fill in a state. (I.e., california, etc). It looks like a javascript/DHTML popup box in MSIE (firefox doesn't do the same, so you need to use MSIE, since that is what the webbrowser control relies on). If I 'click' on the "state" field, a popup box appears. I then can say select "CA" for california, and it updates it. (It now says "CA").
If I progrmatically do it, I would do something like:
WebBrowser1.forms(2).elements(13).value = "CA" ' (sets it to 'california')
WebBrowser1.forms(2).elements(13).item(9).selected = true (makes sure it is 'selected')
However -- within the webbrowser control -- it still appears as if nothing has changed. (In reality it has, i.e., if I submit the form it will submit the correct info), but it just doesn't "update" it.
Do you have any idea how I can do a "forced" refresh (either progrmatically or through some javascript/dhtml refresh), that will correctly then 'update' the field to show that "CA" has been selected?
Thanks very much!
The last VB version I used was VB3 so forgive my VB grammar :)
If the change event has a handler that you want to simulate
WebBrowser1.forms(2).elements(13).item(9).fireEvent ("onchange",WebBrowser1.Document.createEventObject())

dynamics ax 2009 landing page

I would like to redirect some of my users to a specific form in aot when they open dynamics ax 2009. What is the best way to that? Today, they directly go to the role center page.
Thanks
You're asking 2 questions here: how to open a specific form from the code, and how to get something done automatically when AX is opened.
I don't have an access to AX at this moment but the following code should help you with the first question.
FormRun formRun;
;
formRun = new MenuFunction(menuitemdisplaystr(___FormMenuItemName___), MenuItemType::Display).create(new Args(this));
formRun.init();
formRun.run();
formRun.detach();
As to the second question, you just need to add your code to method StartupPost of either Application or Info class.
Firstly you have to create a menu item for the form.
Then in the Info class, modify the startupPost() method by calling the menu item:
new MenuFunction(menuitemDisplayStr(YourMenuItem), MenuItemType::Display).run();

Resources