我有Ruby(1.9.3)和Powershell的问题.
我需要编写一个交互式控制台应用程序,它将处理波兰语的句子.我得到了帮助,可以使用波兰语变音符号检索ARGV元素,但标准输入不能按照我的要求运行.
代码图:
# encoding: UTF-8
target = ARGV[0].dup.force_encoding('CP1250').encode('UTF-8')
puts "string constant = dup?"
puts "dup?".bytes.to_a.to_s
puts "dup?".encoding
puts "target = " +target
puts target.bytes.to_a.to_s
puts target.encoding
puts target.eql? "dup?"
STDIN.set_encoding("CP1250", "UTF-8")
# the line above changes nothing, it can be removed and the result is still the same
# I obviously wanted to mimic the ARGV solution
target2 = STDIN.gets
puts "target2 = " +target2
puts target2.bytes.to_a.to_s
puts target2.encoding
puts target2.eql? "dup?"
Run Code Online (Sandbox Code Playgroud)
输出:
string constant = dup?
[100, 117, …Run Code Online (Sandbox Code Playgroud) 我有一个带有主窗口的应用程序,它有一堆控件,包括空格键,它由一个叫做的简单方法处理onSpacebar().在那个主窗口的顶部,我有一个持久的无模式对话框.无论对话框是否具有焦点,或者主窗口具有焦点,我都需要空格键的行为方式完全相同.
这个对话框由DialogProc支持,它看起来像这样:
BOOL CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_NOTIFY:
std::cout<< "WM_NOTIFY" <<std::endl;
switch(LOWORD(wParam))
{
// which component caused the message?
case COMP_TREE:
if(((LPNMHDR)lParam)->code == NM_DBLCLK){
onDoubleclk()
}
//...
break;
// other components...
}
break;
case WM_CLOSE:
// the dialog can only be closed when the whole app is closed
//EndDialog(hDlg, IDCANCEL);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
}
return FALSE;
}
Run Code Online (Sandbox Code Playgroud)
从我收集的内容中,我应该onSpacebar()在DialogProc中调用我的方法,类似于我如何处理双击.我可以看到,WM_NOTIFY当按下空格键时,对话框会收到该对话框(短语WM_NOTIFY被打印到cout),但我似乎无法将空格键通知与对话框收到的其他众多通知区分开来.
请告诉我如何识别特定WM_NOTIFY是响应空格键按键.