-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include<Python.h> | ||
#include<windows.h> | ||
#include<iostream> | ||
#include<string> | ||
#include<locale> | ||
#include<atlconv.h> | ||
#define PY_SSIZE_T_CLEAN | ||
|
||
|
||
PyObject* ShowWindowWindows(PyObject* self, PyObject* args) { | ||
char* parsed_title; | ||
char* parsed_content; | ||
try | ||
{ | ||
int success = PyArg_ParseTuple(args, "ss", &parsed_title, &parsed_content); | ||
if (!success || !parsed_title || !parsed_content) { | ||
return NULL; | ||
} | ||
} | ||
catch (const std::exception&) | ||
{ | ||
return NULL; | ||
} | ||
|
||
WCHAR* wtitle; | ||
WCHAR* wcontent; | ||
USES_CONVERSION; | ||
wtitle = A2W(parsed_title); | ||
wcontent = A2W(parsed_content); | ||
if (!wtitle || !wcontent) { | ||
return NULL; | ||
} | ||
|
||
long returnvalue = MessageBox(NULL, wcontent, wtitle, MB_OK | MB_ICONWARNING); | ||
return PyLong_FromLong(returnvalue); | ||
} | ||
|
||
|
||
static PyMethodDef PopMethods[] = { | ||
{"PopWin",(PyCFunction)ShowWindowWindows,METH_VARARGS,"Show Native Windows Popups"}, | ||
{NULL,NULL,0,NULL} | ||
}; | ||
static PyModuleDef nativepopup_module = { | ||
PyModuleDef_HEAD_INIT,"nativepopup","Native Popups",0,PopMethods | ||
}; | ||
PyMODINIT_FUNC PyInit_nativepopup() { | ||
return PyModule_Create(&nativepopup_module); | ||
} |