Advertisement
micclly

MessageBoxA.mq4

Feb 24th, 2014
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #property strict
  2.  
  3. #import "user32.dll"
  4. // build 509 まで
  5. //  int      MessageBoxA(int hWnd, string lpText, string lpCaption, int uType);
  6.  
  7. // build 600 以降
  8. // いままで string でつかえていたものは char& []  として宣言しないといけない
  9.    int      MessageBoxA(int hWnd, char &lpText[], char &lpCaption[], int uType);
  10. // Win32API なら、 W 版の関数を使うのが良い
  11.    int      MessageBoxW(int hWnd,string lpText,string lpCaption,int uType);
  12. #import
  13.  
  14. void start()
  15. {
  16.     string title = "Title";
  17.     string message = "Message";
  18.  
  19.     // build 600 以降は string が Unicode (UTF-16) 文字列なので、
  20.     // ANSI 文字列にしてあげる必要がある
  21.     char ansiTitle[];
  22.     StringToCharArray(title, ansiTitle);
  23.  
  24.     char ansiMessage[];
  25.     StringToCharArray(message, ansiMessage);
  26.  
  27.     // 引数には、 StringToCharArray で変換した後の char[] 変数を渡してあげないといけない
  28.     MessageBoxA(0, ansiMessage, ansiTitle, 0);
  29.  
  30.     // Win32API の場合、 W 版を使うとそのまま string が渡せる
  31.     MessageBoxW(0, message, title, 0);
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement