make win-askpass a qt project

This commit is contained in:
royqh1979@gmail.com 2022-02-25 08:58:58 +08:00
parent 8365db47a0
commit 3df0c98031
11 changed files with 97 additions and 176 deletions

View File

@ -5,6 +5,11 @@ SUBDIRS += \
astyle \
consolepauser
win32: {
SUBDIRS += \
redpanda-win-git-askpass
}
APP_NAME = RedPandaCPP
APP_VERSION = 0.14.4

View File

@ -0,0 +1,80 @@
#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include <stdio.h>
HINSTANCE hInst;
LRESULT MainDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
LRESULT TxtPasswordWndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
WNDPROC lpfnTxtPasswordWndProc=NULL;
HWND hMainDlg = NULL;
HWND hwndTxtPassword = NULL;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine, int nCmdShow) {
MSG msg;
hMainDlg = CreateDialog(hInstance, (LPCTSTR)IDD_MAIN_DIALOG, 0,(DLGPROC)MainDlgProc);
ShowWindow(hMainDlg, nCmdShow);
hwndTxtPassword = GetDlgItem(hMainDlg,ID_TXT_PASSWORD);
lpfnTxtPasswordWndProc = (WNDPROC) SetWindowLongPtr(hwndTxtPassword, GWLP_WNDPROC, (LONG_PTR)TxtPasswordWndProc);
HWND hwndTxtPrompt = GetDlgItem(hMainDlg,ID_TXT_PROMPT);
Static_SetText(hwndTxtPrompt, lpCmdLine);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
//In Subclass Proc
LRESULT CALLBACK TxtPasswordWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_KEYDOWN:
if (wParam==VK_RETURN) {
char s[500+1];
Edit_GetText(hwndTxtPassword,s,500);
printf(s);
DestroyWindow(hMainDlg);
return TRUE;
}
break;
}
return CallWindowProc(lpfnTxtPasswordWndProc, hwnd, msg, wParam, lParam);
}
LRESULT MainDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_INITDIALOG :
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam)) {
case IDOK :
case IDCANCEL :
DestroyWindow(hDlg);
return TRUE ;
}
break ;
case WM_KEYUP:
printf("%d\n",wParam);
if (wParam == VK_RETURN) {
DestroyWindow(hDlg);
}
break;
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
};
return FALSE;//返回FALSE给缺省对话框函数DefDlgProc(),表示没有处理本消息
}

View File

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 766 B

View File

@ -0,0 +1,12 @@
TEMPLATE = app
CONFIG += windows
CONFIG -= app_bundle
CONFIG -= qt
DEFINES -= UNICODE
SOURCES += \
main.c
RC_FILE += \
redpanda-git-askpass_private.rc
resource.rc

View File

@ -1,78 +0,0 @@
#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include <stdio.h>
HINSTANCE hInst;
LRESULT MainDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
LRESULT TxtPasswordWndProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
WNDPROC lpfnTxtPasswordWndProc=NULL;
HWND hMainDlg = NULL;
HWND hwndTxtPassword = NULL;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
MSG msg;
hMainDlg = CreateDialog(hInstance, (LPCTSTR)IDD_MAIN_DIALOG, 0,(DLGPROC)MainDlgProc);
ShowWindow(hMainDlg, nCmdShow);
hwndTxtPassword = GetDlgItem(hMainDlg,ID_TXT_PASSWORD);
lpfnTxtPasswordWndProc = (WNDPROC) SetWindowLongPtr(hwndTxtPassword, GWLP_WNDPROC, (LONG_PTR)TxtPasswordWndProc);
HWND hwndTxtPrompt = GetDlgItem(hMainDlg,ID_TXT_PROMPT);
Static_SetText(hwndTxtPrompt, lpCmdLine);
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
//In Subclass Proc
LRESULT CALLBACK TxtPasswordWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg) {
case WM_KEYDOWN:
if (wParam==VK_RETURN) {
char s[500+1];
Edit_GetText(hwndTxtPassword,s,500);
printf(s);
DestroyWindow(hMainDlg);
return TRUE;
}
break;
}
return CallWindowProc(lpfnTxtPasswordWndProc, hwnd, msg, wParam, lParam);
}
LRESULT MainDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_INITDIALOG :
return TRUE ;
case WM_COMMAND :
switch (LOWORD (wParam)) {
case IDOK :
case IDCANCEL :
DestroyWindow(hDlg);
return TRUE ;
}
break ;
case WM_KEYUP:
printf("%d\n",wParam);
if (wParam == VK_RETURN) {
DestroyWindow(hDlg);
}
break;
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
};
return FALSE;//返回FALSE给缺省对话框函数DefDlgProc(),表示没有处理本消息
}

View File

@ -1,98 +0,0 @@
[Project]
filename = redpanda-git-askpass.dev
name = redpanda-git-askpass
UnitCount = 3
Type = 0
Ver = 3
ObjFiles =
Includes =
Libs =
PrivateResource = redpanda-git-askpass_private.rc
ResourceIncludes =
MakeIncludes =
Compiler =
CppCompiler =
Linker =
IsCpp = 1
Icon = redpanda-git-askpass.ico
ExeOutput =
ObjectOutput =
LogOutput =
LogOutputEnabled = 0
OverrideOutput = 0
OverrideOutputName =
HostApplication =
UseCustomMakefile = 0
CustomMakefile =
UsePrecompiledHeader = 0
PrecompiledHeader =
CommandLine =
Folders =
IncludeVersionInfo = 0
SupportXPThemes = 0
CompilerSet = 0
CompilerSetType = 0
CompilerSettings = 000000a000000000000010001
StaticLink = 1
AddCharset = 1
Encoding = AUTO
ModelType = 0
UseUTF8 = 0
[Unit1]
FileName = main.c
CompileCpp = 1
Folder =
Compile = 1
Link = 1
Priority = 1000
OverrideBuildCmd = 0
BuildCmd =
DetectEncoding = 1
FileEncoding = AUTO
[Unit2]
FileName = resource.rc
Folder = Resources
Compile = 1
Link = 1
Priority = 1000
OverrideBuildCmd = 0
BuildCmd =
DetectEncoding = 1
FileEncoding = AUTO
[Unit3]
FileName = resource.h
CompileCpp = 1
Folder =
Compile = 1
Link = 1
Priority = 1000
OverrideBuildCmd = 0
BuildCmd =
DetectEncoding = 1
FileEncoding = AUTO
[VersionInfo]
Major = 1
Minor = 0
Release = 0
Build = 0
LanguageID = 1033
CharsetID = 1252
CompanyName =
FileVersion =
FileDescription = Developed using the Red Panda C++ IDE
InternalName =
LegalCopyright =
LegalTrademarks =
OriginalFilename =
ProductName =
ProductVersion =
AutoIncBuildNr = 0
SyncProduct = 1