• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Language resource files

I am using resource files to allow my app to use different languages depending on the regional settings selected on the local computer.

I can not find out how to get the captions on msgbox buttons to change.

Normal buttons are no problem but when i use a msgbox and use vbYesNo (for example) to include the buttons yes and no i cant get these buttons to change their caption.

Any clues?
0
Kels
Asked:
Kels
  • 2
1 Solution
 
SethiCommented:
Create your own Messagebox using a form and sizing it like a messagebox. Then put a label on the form and two command buttons. Use the strings from Resource file. The msgbox that is displayed by VB uses Windows API's so you will have to use Win API's to change the text in that msgbox. Use the following sites to look into that code:
http://www.allapi.net/
or www.planet-source-code.com
0
 
VBtomCommented:
Sethi's right, the captions on the textbox only depend on the language of the OS. Easiest alternative is creating a form that looks similar.
0
 
BelfryCommented:
Yet there is another way:hooking
you can hook the creation of the msgbox, and then change the text for the buttons.

for clearance, here i provide you an example:

'.bas module
public hHook as long

public sub HookMe(frm as Form)
hHook=SetWindowsHookEx(WH_CBT, AddressOf MsgBoxHookProc, App.hInstance, App.ThreadID)
end sub

public sub unhookMe(frm as Form)
UnhookWindowsHookEx hHook
end sub

public function MsgBoxhookProc(ByVal uMsg As Long, _
                               ByVal wParam As Long, _
                               ByVal lParam As Long) As Long
if uMsg=HCBT_ACTIVATE then
    SetDlgItemText wParam, IDOK, "MyOk"
    SetDlgItemText wParam, IDCANCEL,"MyCancel"
    UnhookWindowsHookEx hHook
end if
MsgBoxHookProc=False
end function


that's it, try! enjoy programming!
0
 
BelfryCommented:
sorry, some supplement:

'in the form code,before using msgbox, just call hook me

HookMe me'i don't know why i put a 'me' as parameter, it's not used, :)
msgbox "my title",vbyesnocancel,...

that's all
(btw. unhookMe is of no use, because once you have changed the texts for the buttons, you immediately unhook the hook)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now