From f75f8851298b392a2c478d200663bd8a7f23abb0 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 3 Dec 2021 21:36:12 +0800 Subject: [PATCH] - enhancement: use token list instead of single string to do code completion ( intial version) - fix: language options in the project wizard don't work - fix: "ake as default language" option in the project wizard doesn't work --- NEWS.md | 5 + RedPandaIDE/mainwindow.cpp | 7 +- RedPandaIDE/project.cpp | 6 +- RedPandaIDE/project.h | 2 +- RedPandaIDE/widgets/codecompletionpopup.cpp | 10 +- RedPandaIDE/widgets/newprojectdialog.cpp | 14 +- RedPandaIDE/widgets/newprojectdialog.h | 2 +- RedPandaIDE/widgets/newprojectdialog.ui | 2 +- Templates/1-WinApp.template | 16 + Templates/2-ConsoleApp.template | 16 + Templates/3-StaticLib.template | 14 + Templates/4-DLL.template | 25 + Templates/5-Empty.template | 14 + Templates/CL_GLUT.ico | Bin 0 -> 4286 bytes Templates/CL_GLUT.template | 17 + Templates/CL_GLUT_cpp.txt | 46 ++ Templates/CL_Graphics.ico | Bin 0 -> 4150 bytes Templates/CL_Graphics.template | 16 + Templates/CL_Graphics_cpp.txt | 32 ++ Templates/CL_Turtle.ico | Bin 0 -> 4286 bytes Templates/CL_Turtle.template | 15 + Templates/CL_Turtle_cpp.txt | 20 + Templates/Communication.ico | Bin 0 -> 2998 bytes Templates/ConsoleApp_c.txt | 8 + Templates/ConsoleApp_cpp.txt | 7 + Templates/ConsoleToo.ico | Bin 0 -> 4286 bytes Templates/DLL.ico | Bin 0 -> 4286 bytes Templates/Dll_c.txt | 34 ++ Templates/Dll_cpp.txt | 44 ++ Templates/Dll_h.txt | 12 + Templates/Dll_hpp.txt | 18 + Templates/Editor.ico | Bin 0 -> 1126 bytes Templates/Empty.ico | Bin 0 -> 4286 bytes Templates/File Management.ico | Bin 0 -> 766 bytes Templates/FileEditor.template | 29 ++ Templates/FileEditor_c.txt | 172 +++++++ Templates/FileEditor_h.txt | 6 + Templates/FileEditor_rc.txt | 18 + Templates/GLFW.ico | Bin 0 -> 4286 bytes Templates/GLFW.template | 32 ++ Templates/GLFW_main.cpp.txt | 111 +++++ Templates/GLFW_shader.frag.txt | 8 + Templates/GLFW_shader.h.txt | 98 ++++ Templates/GLFW_shader.vs.txt | 11 + Templates/Games.ico | Bin 0 -> 6054 bytes Templates/Hello.template | 17 + Templates/HelloInput.template | 16 + Templates/HelloInput_c.txt | 27 ++ Templates/HelloInput_cpp.txt | 27 ++ Templates/Hello_c.txt | 6 + Templates/Hello_cpp.txt | 5 + Templates/Jackpot.template | 17 + Templates/Jackpot_cpp.txt | 88 ++++ Templates/MDIEditor.template | 28 ++ Templates/MDIEditor_c.txt | 433 ++++++++++++++++++ Templates/MDIEditor_h.txt | 24 + Templates/MDIEditor_rc.txt | 31 ++ Templates/OpenGL.template | 17 + Templates/OpenGL.txt | 190 ++++++++ Templates/OpenMP.template | 19 + Templates/OpenMP_c.txt | 17 + Templates/OpenMP_cpp.txt | 26 ++ Templates/Pizza.ico | Bin 0 -> 4286 bytes Templates/Single Dialog Application.ico | Bin 0 -> 766 bytes .../Single Dialog Application.project.ico | Bin 0 -> 766 bytes Templates/Single Dialog Application.template | 28 ++ .../Single_Dialog_Application_main.c.txt | 42 ++ .../Single_Dialog_Application_resource.h.txt | 5 + .../Single_Dialog_Application_resource.rc.txt | 24 + Templates/Software.ico | Bin 0 -> 10278 bytes Templates/StaticLib.ico | Bin 0 -> 4286 bytes Templates/StdThread.template | 19 + Templates/StdThread_c.txt | 2 + Templates/StdThread_cpp.txt | 43 ++ Templates/WinAnim.template | 22 + Templates/WinAnim_c.txt | 191 ++++++++ Templates/WinAnim_rc.txt | 2 + Templates/WinApp_c.txt | 66 +++ Templates/Windows.ico | Bin 0 -> 4286 bytes Templates/ball.bmp | Bin 0 -> 630 bytes Templates/ballmask.bmp | Bin 0 -> 190 bytes 81 files changed, 2302 insertions(+), 17 deletions(-) create mode 100644 Templates/1-WinApp.template create mode 100644 Templates/2-ConsoleApp.template create mode 100644 Templates/3-StaticLib.template create mode 100644 Templates/4-DLL.template create mode 100644 Templates/5-Empty.template create mode 100644 Templates/CL_GLUT.ico create mode 100644 Templates/CL_GLUT.template create mode 100644 Templates/CL_GLUT_cpp.txt create mode 100644 Templates/CL_Graphics.ico create mode 100644 Templates/CL_Graphics.template create mode 100644 Templates/CL_Graphics_cpp.txt create mode 100644 Templates/CL_Turtle.ico create mode 100644 Templates/CL_Turtle.template create mode 100644 Templates/CL_Turtle_cpp.txt create mode 100644 Templates/Communication.ico create mode 100644 Templates/ConsoleApp_c.txt create mode 100644 Templates/ConsoleApp_cpp.txt create mode 100644 Templates/ConsoleToo.ico create mode 100644 Templates/DLL.ico create mode 100644 Templates/Dll_c.txt create mode 100644 Templates/Dll_cpp.txt create mode 100644 Templates/Dll_h.txt create mode 100644 Templates/Dll_hpp.txt create mode 100644 Templates/Editor.ico create mode 100644 Templates/Empty.ico create mode 100644 Templates/File Management.ico create mode 100644 Templates/FileEditor.template create mode 100644 Templates/FileEditor_c.txt create mode 100644 Templates/FileEditor_h.txt create mode 100644 Templates/FileEditor_rc.txt create mode 100644 Templates/GLFW.ico create mode 100644 Templates/GLFW.template create mode 100644 Templates/GLFW_main.cpp.txt create mode 100644 Templates/GLFW_shader.frag.txt create mode 100644 Templates/GLFW_shader.h.txt create mode 100644 Templates/GLFW_shader.vs.txt create mode 100644 Templates/Games.ico create mode 100644 Templates/Hello.template create mode 100644 Templates/HelloInput.template create mode 100644 Templates/HelloInput_c.txt create mode 100644 Templates/HelloInput_cpp.txt create mode 100644 Templates/Hello_c.txt create mode 100644 Templates/Hello_cpp.txt create mode 100644 Templates/Jackpot.template create mode 100644 Templates/Jackpot_cpp.txt create mode 100644 Templates/MDIEditor.template create mode 100644 Templates/MDIEditor_c.txt create mode 100644 Templates/MDIEditor_h.txt create mode 100644 Templates/MDIEditor_rc.txt create mode 100644 Templates/OpenGL.template create mode 100644 Templates/OpenGL.txt create mode 100644 Templates/OpenMP.template create mode 100644 Templates/OpenMP_c.txt create mode 100644 Templates/OpenMP_cpp.txt create mode 100644 Templates/Pizza.ico create mode 100644 Templates/Single Dialog Application.ico create mode 100644 Templates/Single Dialog Application.project.ico create mode 100644 Templates/Single Dialog Application.template create mode 100644 Templates/Single_Dialog_Application_main.c.txt create mode 100644 Templates/Single_Dialog_Application_resource.h.txt create mode 100644 Templates/Single_Dialog_Application_resource.rc.txt create mode 100644 Templates/Software.ico create mode 100644 Templates/StaticLib.ico create mode 100644 Templates/StdThread.template create mode 100644 Templates/StdThread_c.txt create mode 100644 Templates/StdThread_cpp.txt create mode 100644 Templates/WinAnim.template create mode 100644 Templates/WinAnim_c.txt create mode 100644 Templates/WinAnim_rc.txt create mode 100644 Templates/WinApp_c.txt create mode 100644 Templates/Windows.ico create mode 100644 Templates/ball.bmp create mode 100644 Templates/ballmask.bmp diff --git a/NEWS.md b/NEWS.md index d91293e4..6d0e10db 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +Version 0.11.0 For Dev-C++ 7 Beta + - enhancement: use token list instead of single string to do code completion ( intial version) + - fix: language options in the project wizard don't work + - fix: "ake as default language" option in the project wizard doesn't work + Version 0.10.4 For Dev-C++ 7 Beta - fix: can't correctly undo/redo indent - fix: can't correctly undo/redo unindent diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index fcf88623..f7f4c372 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -4594,6 +4594,10 @@ void MainWindow::on_actionNew_Project_triggered() { NewProjectDialog dialog; if (dialog.exec() == QDialog::Accepted) { + if (dialog.makeDefaultLanguage()) { + pSettings->editor().setDefaultFileCpp(dialog.isCppProject()); + pSettings->editor().save(); + } if (dialog.useAsDefaultProjectDir()) { pSettings->dirs().setProjectDir(dialog.getLocation()); pSettings->dirs().save(); @@ -4656,14 +4660,13 @@ void MainWindow::on_actionNew_Project_triggered() // Create an empty project mProject = std::make_shared(s,dialog.getProjectName()); - if (!mProject->assignTemplate(dialog.getTemplate())) { + if (!mProject->assignTemplate(dialog.getTemplate(),dialog.isCppProject())) { mProject = nullptr; QMessageBox::critical(this, tr("New project fail"), tr("Can't assign project template"), QMessageBox::Ok); } - mProject->options().useGPP = dialog.isCppProject(); mProject->saveAll(); updateProjectView(); } diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index c548b9d0..afd4a175 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -624,14 +624,14 @@ void Project::setCompilerSet(int compilerSetIndex) } } -bool Project::assignTemplate(const std::shared_ptr aTemplate) +bool Project::assignTemplate(const std::shared_ptr aTemplate, bool useCpp) { if (!aTemplate) { return true; } - mOptions = aTemplate->options(); mOptions.compilerSet = pSettings->compilerSets().defaultIndex(); + mOptions.useGPP = useCpp; updateCompilerSetType(); mOptions.icon = aTemplate->icon(); @@ -653,7 +653,7 @@ bool Project::assignTemplate(const std::shared_ptr aTemplate) PTemplateUnit templateUnit = aTemplate->unit(i); QString s; PProjectUnit unit; - if (aTemplate->options().useGPP) { + if (options().useGPP) { s = templateUnit->CppText; unit = newUnit(mNode, templateUnit->CppName); } else { diff --git a/RedPandaIDE/project.h b/RedPandaIDE/project.h index bcd04b6e..a9c80576 100644 --- a/RedPandaIDE/project.h +++ b/RedPandaIDE/project.h @@ -164,7 +164,7 @@ public: void setCompilerSet(int compilerSetIndex); //void showOptions(); - bool assignTemplate(const std::shared_ptr aTemplate); + bool assignTemplate(const std::shared_ptr aTemplate, bool useCpp); //void saveToLog(); std::shared_ptr cppParser(); diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index aed9c122..eb6955a5 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -947,14 +947,14 @@ void CodeCompletionPopup::getCompletionFor(const QStringList &expression, const scopeName, mCurrentStatement, parentTypeStatement); - qDebug()<fullName; +// qDebug()<<"found: "<fullName; if (memberOperator == "::") { if (ownerStatement->kind==StatementKind::skNamespace) { //there might be many statements corresponding to one namespace; diff --git a/RedPandaIDE/widgets/newprojectdialog.cpp b/RedPandaIDE/widgets/newprojectdialog.cpp index 076fa4d2..cbc2635e 100644 --- a/RedPandaIDE/widgets/newprojectdialog.cpp +++ b/RedPandaIDE/widgets/newprojectdialog.cpp @@ -81,9 +81,9 @@ bool NewProjectDialog::isCppProject() return ui->rdCppProject->isChecked(); } -bool NewProjectDialog::makeProjectDefault() +bool NewProjectDialog::makeDefaultLanguage() { - return ui->chkMakeDefault->isChecked(); + return ui->chkMakeDefaultLanguage->isChecked(); } void NewProjectDialog::addTemplate(const QString &filename) @@ -187,15 +187,21 @@ void NewProjectDialog::on_lstTemplates_currentItemChanged(QListWidgetItem *curre PProjectTemplate t = mTemplates[index]; ui->lblDescription->setText(t->description()); if (t->options().useGPP) { + ui->rdCProject->setEnabled(false); ui->rdCppProject->setChecked(true); } else { - ui->rdCProject->setChecked(true); + ui->rdCProject->setEnabled(true); + if (pSettings->editor().defaultFileCpp()) { + ui->rdCppProject->setChecked(true); + } else { + ui->rdCProject->setChecked(true); + } } } else { ui->lblDescription->setText(""); ui->rdCProject->setChecked(false); ui->rdCppProject->setChecked(false); - ui->chkMakeDefault->setChecked(false); + ui->chkMakeDefaultLanguage->setChecked(false); } ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled( current && !ui->txtProjectName->text().isEmpty() diff --git a/RedPandaIDE/widgets/newprojectdialog.h b/RedPandaIDE/widgets/newprojectdialog.h index 95690fd0..f345d750 100644 --- a/RedPandaIDE/widgets/newprojectdialog.h +++ b/RedPandaIDE/widgets/newprojectdialog.h @@ -23,7 +23,7 @@ public: bool useAsDefaultProjectDir(); bool isCProject(); bool isCppProject(); - bool makeProjectDefault(); + bool makeDefaultLanguage(); private slots: void updateView(); void updateProjectLocation(); diff --git a/RedPandaIDE/widgets/newprojectdialog.ui b/RedPandaIDE/widgets/newprojectdialog.ui index 414d8186..d0829218 100644 --- a/RedPandaIDE/widgets/newprojectdialog.ui +++ b/RedPandaIDE/widgets/newprojectdialog.ui @@ -50,7 +50,7 @@ 10 - + Make default language diff --git a/Templates/1-WinApp.template b/Templates/1-WinApp.template new file mode 100644 index 00000000..81312944 --- /dev/null +++ b/Templates/1-WinApp.template @@ -0,0 +1,16 @@ +[Template] +ver=1 +Name=Windows Application +Icon=Windows.ico +Description=A standard Windows application +Category=Basic + +[Unit0] +CName=main.c +CppName=main.cpp +C=winapp_c.txt +Cpp=winapp_c.txt + +[Project] +UnitCount=1 +Type=0 diff --git a/Templates/2-ConsoleApp.template b/Templates/2-ConsoleApp.template new file mode 100644 index 00000000..8ce8216a --- /dev/null +++ b/Templates/2-ConsoleApp.template @@ -0,0 +1,16 @@ +[Template] +ver=1 +Name=Console Application +Icon=ConsoleToo.ico +Description=A console application (MS-DOS window) +Category=Basic + +[Unit0] +CName=main.c +CppName=main.cpp +C=consoleapp_c.txt +Cpp=consoleapp_cpp.txt + +[Project] +UnitCount=1 +Type=1 diff --git a/Templates/3-StaticLib.template b/Templates/3-StaticLib.template new file mode 100644 index 00000000..a2581c18 --- /dev/null +++ b/Templates/3-StaticLib.template @@ -0,0 +1,14 @@ +[Template] +ver=1 +Name=Static Library +Icon=StaticLib.ico +Description=A static library (.a) +Category=Basic + +[Unit0] +CName= +CppName= + +[Project] +UnitCount=1 +Type=2 diff --git a/Templates/4-DLL.template b/Templates/4-DLL.template new file mode 100644 index 00000000..4e88c3ec --- /dev/null +++ b/Templates/4-DLL.template @@ -0,0 +1,25 @@ +[Template] +ver=1 +Name=DLL +Icon=DLL.ico +Description=A Dynamic Link Library (DLL) +Category=Basic + +[Unit0] +CName=dllmain.c +CppName=dllmain.cpp +C=DLL_c.txt +Cpp=Dll_cpp.txt + +[Unit1] +CName=dll.h +CppName=dll.h +C=DLL_h.txt +Cpp=Dll_hpp.txt + +[Project] +UnitCount=2 +Type=3 + +Compiler=-DBUILDING_DLL=1 +CppCompiler=-DBUILDING_DLL=1 \ No newline at end of file diff --git a/Templates/5-Empty.template b/Templates/5-Empty.template new file mode 100644 index 00000000..e85cc803 --- /dev/null +++ b/Templates/5-Empty.template @@ -0,0 +1,14 @@ +[Template] +ver=1 +Name=Empty Project +Icon=Empty.ico +Description=An empty project +Category=Basic + +[Unit0] +CName= +CppName= + +[Project] +UnitCount=1 +Type=1 diff --git a/Templates/CL_GLUT.ico b/Templates/CL_GLUT.ico new file mode 100644 index 0000000000000000000000000000000000000000..2a515ce71acd53202fab695014503a89c3c5e493 GIT binary patch literal 4286 zcmeHLYfx0@89vBGuT2!Y%>}xC#pFm8)Fj4!iL5J!e_FjIooM{z!i0W6qv) zzVm(W^SsadzTfu^3=>6vEX#1e%=t8i5i<;9qKmqi?R0Vde4}rI#LyM$U>JPP+w$@< z{@?3!?&2eQoS(s95cBi%n4X@-`1m-6hKAtt`Ow$bhwkofIGs*791h&NbqjX89ZgM5 zu-R<skM)J~a@D|ymnG6O5Lo)u{&M3ZaUV|3 z;=zMCOiwL@tP&-T2Mv4l&OHQ)>+F00Q`7Slw;7C%O;NmOR|bI}&&~T^Eo^gXX$hCF zv|;bwcd@as429-%c)GA0`(M6Bc{RkF2-_MSnZgS%p2W`Gzs6U0>__p|-=L`IFbZ-{ zV^cvnzQ5;vl$F`BK>5tIRowZW&=030*M>(Xuy0=}L>aF@E_ws3;v_VgB~XehkrrPG zgW@Vq9q+=_WJr&;7B{5Q15l_AK+XOfYWX3kB&VPfRzfMb3Q6*NNMBcmo!hVCW6J;` zg!CmBAGNUG+_zodIs$?4Wth!}VKn|8TKPLrCfcA_*A6zx0cAonQkXhyHrmnJJWaXo zhFtO%vJJSP;aOh0MR0|{|RWbV-AfH;PD&^&d54SGR{ z!*gG8P@WU`f5qqdgmtJW?MJr!Ce|?bv3rXLf3F;bQB#4;^vjUPw?Mg$I3zVvZ0t~_ zUIQzSTuOA%6sUr`uZG#1pm!A=jE4#oKo zC+i_hdlOk1bx^Hsr#Nu&tH(=wyB~uO*Fo2vhdB186_YcQsQLE@3N`iEoLz%w)?2VG z*NXL-EzqVnpg=|ahL2ICy@m~@Hf+pxK%3Ew13&AgTIwf_7jWi}_mLi7jx6~V$|K^P z&_)_H;+va0R^f-SN2sR1vE>?)qi7EM7sxZppp=$iYjG)_DgGO_dbtn6_`4`Q zJ;K|zTpxohwgd8LC(Y@kx^PnLoD}~SeD7mTOu&kv~Xge8Pq3r*TE+3$xUZV-~F zek4$SB~V^I`=uUa%Pf=wRZu53kiK4+wfzvpcyO_N0&dqRa#f8GMKx0`HdFoBkQsfC zYN3njq8$f+{AxRdq?1nMCmlRcCAwkE@LEA!*)#kDZ9?@+zG3%#NeI$1e!XrcOaLrLqCh-%YndC233 z^Zmq$I^^da$J3imVne}O*!QTZrmN}*wo!k|4t?`OcKQmsb&!P0t?%=F;-9d6zRSN_~y%e7zp^g7a# zjzg#ZGgQ*EP>U-l2QEmHjxp1pe|THd>!AKo(cc+sNNa{uKFP$|Vk*uB;mx zxrg=zFVe}6BZuze+q=(_X0L%&)xx}K1o~Y1Zt_B-rL~**D#TuhQ#j5ps$2I;%(*ir z@BXTv<>eqQR5-9@<9TSc-N-I*!L+^?IXQ0RntjMM`H^Svp~&b#c4jx)Tc&A#07s90 zgza1HbOsp4v)}P!&v*TJeh*#G`S9Zxy*RLc7!_r7_L~ZUhW%azPA|(V=dJPaSv21q zr~P#T9j#Ni=bVM>-U58C00#X5JQ!Z2_|IWskrw8awlEjK{7jJ6YVI7ts!md>RG9{|ET2?*9QuT;ad~ literal 0 HcmV?d00001 diff --git a/Templates/CL_GLUT.template b/Templates/CL_GLUT.template new file mode 100644 index 00000000..a21ae8d7 --- /dev/null +++ b/Templates/CL_GLUT.template @@ -0,0 +1,17 @@ +[Template] +ver=1 +Name=GLUT +Icon=CL_GLUT.ico +Description=A simple GLUT program +Category=Multimedia +[Unit0] +CppName=main.cpp +C=CL_GLUT_cpp.txt +[Project] +UnitCount=1 +Type=0 +IsCpp=1 +linker=-lm -lfreeglut_static -lopengl32 -lwinmm -lgdi32_@@__@@_ + + + diff --git a/Templates/CL_GLUT_cpp.txt b/Templates/CL_GLUT_cpp.txt new file mode 100644 index 00000000..4a500867 --- /dev/null +++ b/Templates/CL_GLUT_cpp.txt @@ -0,0 +1,46 @@ +#define FREEGLUT_STATIC +#include +#include + +void keyboard(unsigned char key, int x, int y); +void display(void); + + +int main(int argc, char** argv) +{ + glutInit(&argc, argv); + glutCreateWindow("GLUT Test"); + glutKeyboardFunc(&keyboard); + glutDisplayFunc(&display); + glutMainLoop(); + + return EXIT_SUCCESS; +} + + +void keyboard(unsigned char key, int x, int y) +{ + switch (key) + { + case '\x1B': + exit(EXIT_SUCCESS); + break; + } +} + + +void display() +{ + glClear(GL_COLOR_BUFFER_BIT); + + glColor3f(1.0f, 0.0f, 0.0f); + + glBegin(GL_POLYGON); + glVertex2f(-0.5f, -0.5f); + glVertex2f( 0.5f, -0.5f); + glVertex2f( 0.5f, 0.5f); + glVertex2f(-0.5f, 0.5f); + glEnd(); + + glFlush(); +} \ No newline at end of file diff --git a/Templates/CL_Graphics.ico b/Templates/CL_Graphics.ico new file mode 100644 index 0000000000000000000000000000000000000000..3749cee37907ecc2adf27cf78b7068d2862c8501 GIT binary patch literal 4150 zcmcgvc~H}L7SFDBcK_JU)a_13-SKD{?cuJ|X}4>2yA^LlkSiQ9KrrDF6|2?@6cG!k z2!<<|JAs67gv;UqNJJonoWI;e2qb}0P6b4fBhh^!V@gxnPG@%doo{}>_x=9f_w(NO zecyZE7ZmCbs6V3KdJ6^b<*3*tDAals3bl5vV_fnV6elO%H`493k4{*p*0*G`38OO*cdqY6!)elYG@r`J0WSDK)BAx$Xn(wJ+m|5rwi? zR_kdZGyP1=*($XQKMai{lQ^y>wD8gKlJ524IXliVPURFereUZ_(YX&EIr)L;9C}*N z+!I@(I#38*>Ce!|@k|?IsKF_WJO=Y9y-sQxaq>^kSwqmd*I_4UCjkO(RPAm|C;@Pwh+Y!-<`H8nLH4u{L-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ZSqn7a6i;T*y6mx;Ikwm;1+ zFlqN05~kom1V?o~gIJf0zI)!M;=~T(=`ajSRG7VF`z!pft_!*3k;KA~1kBXKEkt~CCax~^z?n=Mnj#z+oBTQZJ7CA2 zPq!Eb@&yJQ2f-Gpp+kLy<*2+U8Z@&nyXlE%def@ltdDT%Ua4i-Sy%2BW{AnhxTJ3| zOvNd_9PZ9V@nLfK=~UXi4m3j=#83n=X-bd4Q8Cc z_KkvRTybBIO;4Vo=~5r6#E&KmVMu4^eq=_g%}N$pf&rW^4`d=}2I8Kr59JJFZt6ci zQoQ|}TE4Ug)OZcH$b0O?453)=byMm^5&IR0re;8Z&Hhhe-kkvd@*RUeUG7Jf`qN}U z_|hc1@>ITzfe=dPmeW-oy+72#i=e-H1+@!HV)3I&_T3ckC5cW}Am5Eo+6$?dFDIvF zsI6Vz6nilXB`p-TKtP|baAn}PfwZ1|Y4w)jU&+kRrspyRUBOJb=goF6vSfE&3$9QS z#g%)KTKAD9-V^|odfgO5_ohf-Bk|>kwr>n7@to$dAbKB$*gEj!*`mrjCczZo0CoDo zgl`Q8xlr9pJPX8LWU1#(33MR#6~GoGXqx1Bg}P2ZFf;D}b_3dMOcB^)KMV zC$I+CWX5XMeLrzeJ46whQ|lik-qL?vsZG9Z$ZIm*)()6PCc&7t`Tq@0H0w*-;DlB7 n-3#Z;uM(iu98{*Zm-cGUPRze-KkI?N3i$tJaQ#2 +#include + +void paintstar(double x, double y, double r, double a) +{ + int pt[10]; + for (int n = 0; n < 5; ++n) + { + pt[n*2] = (int)( -cos( PI * 4 / 5 * n + a ) * r + x ); + pt[n*2+1] = (int)( sin( PI * 4 / 5 * n + a) * r + y ); + } + fillpoly(5, pt); +} + +int main() +{ + initgraph( 640, 480 ); + setcolor( RGB(0xff, 0xff, 0xff) ); + setfillcolor( RGB(0, 0, 0xff) ); + setrendermode(RENDER_MANUAL); + + double r = 0; + for ( ; is_run(); delay_fps(60) ) + { + r += 0.02; + if (r > PI * 2) r -= PI * 2; + + cleardevice(); + paintstar(300, 200, 100, r); + } + return 0; +} \ No newline at end of file diff --git a/Templates/CL_Turtle.ico b/Templates/CL_Turtle.ico new file mode 100644 index 0000000000000000000000000000000000000000..b6d9382546c7c4ffeb30d2a010ed5b8955c7c540 GIT binary patch literal 4286 zcmchbhgXzW8phebVApJnCKNR`>;j7PCMrddDhy4Eh#-hjumuyNMoG+OH7hBAC`g9^ zDQXZjcFdY+6p0;sELoLkM24B+x9>M*+$?L3IVb1r9qxQHcV_PM-sgSZ@?m1~CwUAU zXrerul>NoTdM&pf-h`fR zG&=dc%uanL?=+_oR^`E>+GzHi-@(Jq`*dryXyr%x9z8vJ{jaxvj%!>rVj15Xug|f? z#-~~h_cTAybf%oA-CY9RC3fg&|EZ0jTw5Zl9Eq)VC9cGSC3VqUynl(OI-T+r!GCsE zOijld`9-sq0@`4y@s;4RyZ=^^!oU@PaZ#h%;n3MIeFrr6jc>)u;nmkzH8%$ ztJk>o;3kRre)w&(Mpf!WwAz{3Rl-5VRDud^X= zc=OSLrF1;~8J)tFR*zoy6pdEL?T!cRYy66WoC3bc+d^SsA%)uuC@CqXqFhaRaRp_i zW&EvT9g$mn2`rq1s@$2VvdKhN+Tp*&kyH1+mi=T;x`i&$neeC;oRc>X5LfIWTsbhS zz=maN6(_H>aQ=QPM=v%})R4`#{1S@F3;1~3I-*vF;21Ls=a}(KPMCy4)EMHI2eGAi zGnM6~R9C5aw=9WGP0P62d6Sl_2WdK|=5g0U!}*0}!50l`dw8P%naujR%vQS#S5pWp zaVB8vIGnSG85-7?k*Y!1#EoKba9=D!`e5$Y z2me$rwwC2lrmp1psiSB*g>T`oN8fGWQ_-JR&fcvMFMsX#FA!cTekyk-u4*z7B`ySP zbHpciENMCMsCU$opPNlYh7Tjd`!OQ6FQX$&88`bCtfSt`~== zv7@G%n)(_dm-*ne(1{t#T(M0Y#;Do-@JO}6C&LM!bZ6Y>+cH-5I@S?`n4C0;DakH` zE}c$!Z7F3%mHa5$QS_~7TN#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>*i3TGR6?C#+4!zbLjep7NpD{XDxa`x0W1iZNIbuU}3$lrtN1`|mk_Z+i+v<4Hv!OmKE0qc)uM#uyeg3J<%3 z1z+N!UZ(Vi32HC7ubR$1$xVj)2+{EGI&W{lUhnTbzQqTJ7L%MiQ?wpWdULpNpb{Ix zSg<>QIbuWH&Z*2Tok8=p8o^Y0+Gpoh-1tXFkL05Bk1z7s!8NRGp3SnR7}CEK8+NK# zSQ|mg4nLMR#B%J`erekjz-Rf?5Z?wz{xJ)5avr58@92EQ{`N+)4lNTNRAlUmWYe)M kj$GMCherBn(HauFhWj&#Z8778`SoSi{MP>k{$K0=1_16iivR!s literal 0 HcmV?d00001 diff --git a/Templates/CL_Turtle.template b/Templates/CL_Turtle.template new file mode 100644 index 00000000..375babb0 --- /dev/null +++ b/Templates/CL_Turtle.template @@ -0,0 +1,15 @@ +[Template] +ver=1 +Name=Turtle Graphics +Icon=CL_Turtle.ico +Description=A simple program using Turtle Graphics (https://github.com/royqh1979/libturtle) +Category=Multimedia +[Unit0] +CppName=main.cpp +Cpp=CL_Turtle_cpp.txt +[Project] +UnitCount=1 +Type=0 +IsCpp=1 +linker=-lturtle -lgraphics -luuid -lmsimg32 -lgdi32 -limm32 -lole32 -loleaut32 -lwinmm -lgdiplus_@@__@@_ + diff --git a/Templates/CL_Turtle_cpp.txt b/Templates/CL_Turtle_cpp.txt new file mode 100644 index 00000000..6b2f10d1 --- /dev/null +++ b/Templates/CL_Turtle_cpp.txt @@ -0,0 +1,20 @@ +#include + +int main() { + int n; + initWorld(800,600); + setSpeed(1000); + //setImmediate(1); + + n=50; + for (int i=0;i$BDWFBz7Bfn0G%!|+$`d`VF!oD~(JKxKpZmCZzb`bLlLIwwi=pohQ#!nwm*B+%Q%iRCDWA(-Z?$(({&ta zHkPC>}V^i`xIq_T$m%;L%ejbJv`oJKS*=GuoHC#>6^*95-hA z&$WMkW+xcsG6Uw9t+QN12aMvzV347o)Aj3(1zY0jEgryv(^Ffp=I=c4V!SXKB|D&? z!O|B-=@u!_JCiM&PH!wE`y_>bh$oSIwb(7AL@o%`y0&daauPI9u}Z(X|Pz1FYm-t*pZ zPsYFeB*U?hc5I|JG_rYUWaYp}w#9p{$KJ6><-JJpwMd~Xl3$bI2|mPo_+5M%zkyxn zSj8{nm+)Eq9G<-GHok`6#INA9SmCJzFL=QVUe@FUAL2dyF20Q4z_0T&xQbuKFX6NJ zIs6zOZ}0|h@CI-2=X{R&yyx?pPnpk}^<#XDAL0-3 z2YAiiLhqp~=pwp+&XfNHAL2dyF20Q4z^~(1@yqxnd=@{4CvUrrui-cGEBNdU)!}#0 z2|mPo_+5M%zmXNQPBmAl<}%e>qMBK%IfozPWBd?*h(Ex$@Vw8*d-w{zh%eyt`a2G9 z@CI-225(po+jY!#y=S{#vt4DjYi&(rjF0g{{2~4T-@@PU`p5}B#C!N%d>Oxizv1;E z?@-$K8h#VMg3sb_D$vlJ;6uEJ-^EjDv%!O1U!b8G<74~~e~3T8Q=A(LG~{nUo1@0D z$+5zb<+!OpXJ=>f>C-3q@Zp0T9UV!(-6VUBi;MsUwL)7b+f$Jjd z6gobx)oXQtZ9CP7B~W8h@Q@TB1yN)tsCT)D*vBMJ{qMz^ftp!Rt#_+kKLON8<933` zr?@r)i%bFQ*9`TunnxWgNg0$b*)?qeFh0Lc_l zMT)1&h%4ROk6Jxm^Jn>>_lX$wICUw<#vXK59Db>PgdUyL|Wm H{y*h!V}hYg literal 0 HcmV?d00001 diff --git a/Templates/ConsoleApp_c.txt b/Templates/ConsoleApp_c.txt new file mode 100644 index 00000000..e10d74fc --- /dev/null +++ b/Templates/ConsoleApp_c.txt @@ -0,0 +1,8 @@ +#include +#include + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char *argv[]) { + return 0; +} \ No newline at end of file diff --git a/Templates/ConsoleApp_cpp.txt b/Templates/ConsoleApp_cpp.txt new file mode 100644 index 00000000..5627b733 --- /dev/null +++ b/Templates/ConsoleApp_cpp.txt @@ -0,0 +1,7 @@ +#include + +/* run this program using the console pauser or add your own getch, system("pause") or input loop */ + +int main(int argc, char** argv) { + return 0; +} \ No newline at end of file diff --git a/Templates/ConsoleToo.ico b/Templates/ConsoleToo.ico new file mode 100644 index 0000000000000000000000000000000000000000..4238e81ffbf396829bb934b62ed82e17319d2724 GIT binary patch literal 4286 zcmd^?A&lcl5JkOOa07!*VYg-%7-)713=9knG&D3>U}$J)YUxN|V5CEVfq|ic17}(9 zf90;k$s`%wX-+!ny!vB1cK5IP^}E`eBwzIJ+qZRNM2ru?*iSwoG}_)Uw(f#W;i}xk4B?V*L5HcawK04v>>kO zbZVSMS%y3>LS7Vs>rydQ8do>X1-j?As;cdISyuKgWAZ!?E3nGLav zH?7Fm`Liq&Um50$g|Ligt`}hj=8k#DG(MX-X1bn*X*NWr`wJ$@>vBH}<1`JW^1=_U z0sN(MSrW5ie+SDY4-4h9SoWAN6(_KG`_RSL_eyZq8>Cl0)B{2D_qrau6BX5G;1=!c~}KgeH~v_E)|U16X?8dNSFN-C;b+$l+Fh`0*e$a{jf(0E^v_zgyz>it@() z0DgMr@c#lme+YZkpBjLp_Pl5C_wWpH6KfyaB_4~#e9U(gUheE0ppJWsfB#ZTyoJx% z<32(Yy=Y??C-8mVf0N@+LHljLFL`goGllJoc-pzqAMHQl{H*7!>mfJ%|K|fOek93n ce-E~u0Zfi%=@g~aO=DfxowY)@ zpcl`=;X2~wx9~q52amt2bDKw-_6ttm5ox0F^(TT3e>FPvYBdkIq~JT}eQ-~I@Toi6 zw{4@m&*r~K&w^u6VM-f`Hss-g3N=RKDT4wrSH2348c^Nai{{r2jut>zMam#ROQ z6HZa2YhTw}xl@6jIda%pFI-~8|2v0H`gfBbL+)T7RM&x-tJ+qo+r#2P9@=_*Gzqz* zedzD8^5b9pKFDh!e}6pl81=7IS0_Dd>Py{q4j$P3p!G>d0u7cc)j>yB=sC@B@ag?q z{tG=f=$S?y?01d0XueN%0E_;O)#r)ooTah%^FcXx`ps@QSTF2c&n%V;-$Tscv5z~; z#D$=@m{;I{Isb6&=Z^Z|(5n^`eycju8|0R`(iV$_rSkKj>+aB7C+*-6@X{_O z*i*toC!VjA+g7~|4`%nZdB9rB+zt46Y|m`aTI7_|Rvh5b3b&zeMmuPVx#-ixWItC6DPHb1$IV>8O0v3;3{WRR?hgdmfee*906Ca2RVb zSgY$o@1`&53%nWp5q!%1jb=DH1bqDIb)grgUTiAqDBUW}2j0iKOYwId(Rp3q;kAIv zq=)AsY`lSfM9+GvT!=*dK^^dBz-K=AJwtyv3+OwinZlY!y-TePV~jkg&8Wqt9-}5> zZK%)4L2H|yCwH`;uSaKm`RbrN1|3-gkD9}+bSPDKaI(6xT$&WxYrw-vj|wejder+- z6F8iCNDFj{H4o{h&;ucVj&R_6bfJHkjqHP%C-BZxx2+;mJ@Sc1;4s!?;({jPfIre) zp4ZyOta9QTPwT<8wP4OAoWsQ_SMU<;by8Q1eK6yJ7D10!f3y}e2UTZgEWO2y822{s z+lRq{J#Z<#H+omB_0e>Iu(bs>@bdRpJol%)h~$bKv*9zr|CYM`=s#DVTF` zBR8IDnGw zk2DLJEqMDqSofZR$6mDzb>*Gxu^Z`+PpHwH!%AAM#34L?@7>>XkJ;YKW6VadH(7f2 zX{_E`ESKh_&41DU9(T68p6Z+je9%t7&jiRqpJn0zX ftNxdR0Dqj~QO8gA^y?@4rlUoVV?2E^`}XB8wMT{8 literal 0 HcmV?d00001 diff --git a/Templates/Dll_c.txt b/Templates/Dll_c.txt new file mode 100644 index 00000000..10b41500 --- /dev/null +++ b/Templates/Dll_c.txt @@ -0,0 +1,34 @@ +/* Replace "dll.h" with the name of your header */ +#include "dll.h" +#include + +DLLIMPORT void HelloWorld() +{ + MessageBox(0,"Hello World from DLL!\n","Hi",MB_ICONINFORMATION); +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + switch(fdwReason) + { + case DLL_PROCESS_ATTACH: + { + break; + } + case DLL_PROCESS_DETACH: + { + break; + } + case DLL_THREAD_ATTACH: + { + break; + } + case DLL_THREAD_DETACH: + { + break; + } + } + + /* Return TRUE on success, FALSE on failure */ + return TRUE; +} diff --git a/Templates/Dll_cpp.txt b/Templates/Dll_cpp.txt new file mode 100644 index 00000000..9ff2a678 --- /dev/null +++ b/Templates/Dll_cpp.txt @@ -0,0 +1,44 @@ +/* Replace "dll.h" with the name of your header */ +#include "dll.h" +#include + +DllClass::DllClass() +{ + +} + +DllClass::~DllClass() +{ + +} + +void DllClass::HelloWorld() +{ + MessageBox(0, "Hello World from DLL!\n","Hi",MB_ICONINFORMATION); +} + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + switch(fdwReason) + { + case DLL_PROCESS_ATTACH: + { + break; + } + case DLL_PROCESS_DETACH: + { + break; + } + case DLL_THREAD_ATTACH: + { + break; + } + case DLL_THREAD_DETACH: + { + break; + } + } + + /* Return TRUE on success, FALSE on failure */ + return TRUE; +} diff --git a/Templates/Dll_h.txt b/Templates/Dll_h.txt new file mode 100644 index 00000000..394eb826 --- /dev/null +++ b/Templates/Dll_h.txt @@ -0,0 +1,12 @@ +#ifndef _DLL_H_ +#define _DLL_H_ + +#if BUILDING_DLL +#define DLLIMPORT __declspec(dllexport) +#else +#define DLLIMPORT __declspec(dllimport) +#endif + +DLLIMPORT void HelloWorld(); + +#endif diff --git a/Templates/Dll_hpp.txt b/Templates/Dll_hpp.txt new file mode 100644 index 00000000..e2f2084a --- /dev/null +++ b/Templates/Dll_hpp.txt @@ -0,0 +1,18 @@ +#ifndef _DLL_H_ +#define _DLL_H_ + +#if BUILDING_DLL +#define DLLIMPORT __declspec(dllexport) +#else +#define DLLIMPORT __declspec(dllimport) +#endif + +class DLLIMPORT DllClass +{ + public: + DllClass(); + virtual ~DllClass(); + void HelloWorld(); +}; + +#endif diff --git a/Templates/Editor.ico b/Templates/Editor.ico new file mode 100644 index 0000000000000000000000000000000000000000..f58b11a8711a00a32d6e4b7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N4=-P2%^xBU{{StjsdxYY literal 0 HcmV?d00001 diff --git a/Templates/File Management.ico b/Templates/File Management.ico new file mode 100644 index 0000000000000000000000000000000000000000..09099e21774f7cdcb6188b71b06eee6b45079345 GIT binary patch literal 766 zcmb7?I}XAy42E5Vl%9ZGi1SMSVj126eq?x +#include "main.h" + +BOOL LoadFile(HWND hEdit, LPSTR pszFileName) { + HANDLE hFile; + BOOL bSuccess = FALSE; + + hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0); + if(hFile != INVALID_HANDLE_VALUE) { + DWORD dwFileSize; + dwFileSize = GetFileSize(hFile, NULL); + if(dwFileSize != 0xFFFFFFFF) { + LPSTR pszFileText; + pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1); + if(pszFileText != NULL) { + DWORD dwRead; + if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL)) { + pszFileText[dwFileSize] = 0; // Null terminator + if(SetWindowText(hEdit, pszFileText)) + bSuccess = TRUE; // It worked! + } + GlobalFree(pszFileText); + } + } + CloseHandle(hFile); + } + return bSuccess; +} + +BOOL SaveFile(HWND hEdit, LPSTR pszFileName) { + HANDLE hFile; + BOOL bSuccess = FALSE; + + hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if(hFile != INVALID_HANDLE_VALUE) { + DWORD dwTextLength; + dwTextLength = GetWindowTextLength(hEdit); + if(dwTextLength > 0) { + LPSTR pszText; + pszText = (LPSTR)GlobalAlloc(GPTR, dwTextLength + 1); + if(pszText != NULL) { + if(GetWindowText(hEdit, pszText, dwTextLength + 1)) { + DWORD dwWritten; + if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL)) + bSuccess = TRUE; + } + GlobalFree(pszText); + } + } + CloseHandle(hFile); + } + return bSuccess; +} + +BOOL DoFileOpenSave(HWND hwnd, BOOL bSave) { + OPENFILENAME ofn; + char szFileName[MAX_PATH]; + + ZeroMemory(&ofn, sizeof(ofn)); + szFileName[0] = 0; + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "txt"; + + if(bSave) { + ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; + if(GetSaveFileName(&ofn)) { + if(!SaveFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName)) { + MessageBox(hwnd, "Save file failed.", "Error",MB_OK|MB_ICONEXCLAMATION); + return FALSE; + } + } + } else { + ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY; + if(GetOpenFileName(&ofn)) { + if(!LoadFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName)) { + MessageBox(hwnd, "Load of file failed.", "Error",MB_OK|MB_ICONEXCLAMATION); + return FALSE; + } + } + } + return TRUE; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { + switch(Message) { + case WM_CREATE: + CreateWindow("EDIT", "",WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_WANTRETURN,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,hwnd, (HMENU)IDC_MAIN_TEXT, GetModuleHandle(NULL), NULL); + SendDlgItemMessage(hwnd, IDC_MAIN_TEXT, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE,0)); + break; + case WM_SIZE: + if(wParam != SIZE_MINIMIZED) + MoveWindow(GetDlgItem(hwnd, IDC_MAIN_TEXT), 0, 0, LOWORD(lParam),HIWORD(lParam), TRUE); + break; + case WM_SETFOCUS: + SetFocus(GetDlgItem(hwnd, IDC_MAIN_TEXT)); + break; + case WM_COMMAND: + switch(LOWORD(wParam)) { + case CM_FILE_OPEN: + DoFileOpenSave(hwnd, FALSE); + break; + case CM_FILE_SAVEAS: + DoFileOpenSave(hwnd, TRUE); + break; + case CM_FILE_EXIT: + PostMessage(hwnd, WM_CLOSE, 0, 0); + break; + case CM_ABOUT: + MessageBox (NULL, "File Editor for Windows!\nCreated using the Win32 API" , "About...", 0); + break; + } + break; + case WM_CLOSE: + DestroyWindow(hwnd); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hwnd, Message, wParam, lParam); + } + return 0; +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow) { + WNDCLASSEX wc; + HWND hwnd; + MSG Msg; + + wc.cbSize = sizeof(WNDCLASSEX); + wc.style = 0; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wc.lpszMenuName = "MAINMENU"; + wc.lpszClassName = "WindowClass"; + wc.hIconSm = LoadIcon(hInstance,"A"); /* A is name used by project icons */ + + if(!RegisterClassEx(&wc)) { + MessageBox(0,"Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK|MB_SYSTEMMODAL); + return 0; + } + + hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","File Editor Example Program",WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + 320,240, + NULL, NULL, hInstance, NULL); + + if(hwnd == NULL) { + MessageBox(0, "Window Creation Failed!", "Error!",MB_ICONEXCLAMATION|MB_OK|MB_SYSTEMMODAL); + return 0; + } + + ShowWindow(hwnd,1); + UpdateWindow(hwnd); + + while(GetMessage(&Msg, NULL, 0, 0) > 0) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + return Msg.wParam; +} diff --git a/Templates/FileEditor_h.txt b/Templates/FileEditor_h.txt new file mode 100644 index 00000000..de62f0d0 --- /dev/null +++ b/Templates/FileEditor_h.txt @@ -0,0 +1,6 @@ +#define CM_FILE_SAVEAS 9072 +#define CM_FILE_EXIT 9071 +#define CM_FILE_OPEN 9070 +#define CM_ABOUT 9069 + +#define IDC_MAIN_TEXT 1001 diff --git a/Templates/FileEditor_rc.txt b/Templates/FileEditor_rc.txt new file mode 100644 index 00000000..98abdae6 --- /dev/null +++ b/Templates/FileEditor_rc.txt @@ -0,0 +1,18 @@ +#include "main.h" + +MAINMENU MENU +{ + POPUP "&File" + { + MENUITEM "&Open...", CM_FILE_OPEN + MENUITEM "Save &As...", CM_FILE_SAVEAS + MENUITEM SEPARATOR + MENUITEM "E&xit", CM_FILE_EXIT + } + + POPUP "&Help" + { + MENUITEM "&About", CM_ABOUT + } +} + diff --git a/Templates/GLFW.ico b/Templates/GLFW.ico new file mode 100644 index 0000000000000000000000000000000000000000..2a515ce71acd53202fab695014503a89c3c5e493 GIT binary patch literal 4286 zcmeHLYfx0@89vBGuT2!Y%>}xC#pFm8)Fj4!iL5J!e_FjIooM{z!i0W6qv) zzVm(W^SsadzTfu^3=>6vEX#1e%=t8i5i<;9qKmqi?R0Vde4}rI#LyM$U>JPP+w$@< z{@?3!?&2eQoS(s95cBi%n4X@-`1m-6hKAtt`Ow$bhwkofIGs*791h&NbqjX89ZgM5 zu-R<skM)J~a@D|ymnG6O5Lo)u{&M3ZaUV|3 z;=zMCOiwL@tP&-T2Mv4l&OHQ)>+F00Q`7Slw;7C%O;NmOR|bI}&&~T^Eo^gXX$hCF zv|;bwcd@as429-%c)GA0`(M6Bc{RkF2-_MSnZgS%p2W`Gzs6U0>__p|-=L`IFbZ-{ zV^cvnzQ5;vl$F`BK>5tIRowZW&=030*M>(Xuy0=}L>aF@E_ws3;v_VgB~XehkrrPG zgW@Vq9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58C00#X5JQ!Z2_|IWskrw8awlEjK{7jJ6YVI7ts!md>RG9{|ET2?*9QuT;ad~ literal 0 HcmV?d00001 diff --git a/Templates/GLFW.template b/Templates/GLFW.template new file mode 100644 index 00000000..39db788a --- /dev/null +++ b/Templates/GLFW.template @@ -0,0 +1,32 @@ +[Template] +ver=2 +Name=GLFW +Description=A simple GLFW program +Icon=GLFW.ico +Category=Multimedia +[Unit0] +CppName=main.cpp +Cpp=GLFW_main.cpp.txt +[Unit1] +CppName=shader.h +Cpp=GLFW_shader.h.txt +[Unit2] +CppName=shader.frag +Cpp=GLFW_shader.frag.txt +[Unit3] +CppName=shader.vs +Cpp=GLFW_shader.vs.txt +[Project] +UnitCount=4 +Type=1 +IsCpp=1 +Compiler= +CppCompiler= +Linker=-lglfw3 -lglew32 -lopengl32 -lwinmm -lgdi32_@@__@@_ +CompilerSettings=0000000000110000000001000 +CompilerSet=1 +UseUTF8=0 +StaticLink=1 +AddCharset=1 +IncludeVersionInfo=0 +SupportXPThemes=0 diff --git a/Templates/GLFW_main.cpp.txt b/Templates/GLFW_main.cpp.txt new file mode 100644 index 00000000..3d5cfdae --- /dev/null +++ b/Templates/GLFW_main.cpp.txt @@ -0,0 +1,111 @@ +#include +// GLEW +#define GLEW_STATIC +#include +// GLFW +#include +// Other includes +#include "shader.h" + +// Function prototypes +void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode); + +// Window dimensions +const GLuint WIDTH = 800, HEIGHT = 600; + +// The MAIN function, from here we start the application and run the game loop +int main() +{ + // Init GLFW + glfwInit(); + // Set all the required options for GLFW + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); + + // Create a GLFWwindow object that we can use for GLFW's functions + GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr); + glfwMakeContextCurrent(window); + + // Set the required callback functions + glfwSetKeyCallback(window, key_callback); + + // Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions + glewExperimental = GL_TRUE; + // Initialize GLEW to setup the OpenGL Function pointers + glewInit(); + + // Define the viewport dimensions + glViewport(0, 0, WIDTH, HEIGHT); + + + //读取shader文件,并编译,见shader.h代码 + Shader ourShader("shader.vs", "shader.frag"); + + + // 一维数组,每六个代表一个顶点属性,前三个代表位置属性,后三个代表颜色属性 + GLfloat vertices[] = { + // Positions // Colors + 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, // Bottom Right + -0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, // Bottom Left + 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f // Top + }; + GLuint VBO, VAO;//声明顶点缓冲,声明顶点数组用于管理顶点数据 + glGenVertexArrays(1, &VAO);//创建顶点数组,返回一个独一无二的整数,标识数组 + glGenBuffers(1, &VBO);//创建顶点缓冲,返回一个独一无二的整数,标识缓冲区 + + glBindVertexArray(VAO);//绑定顶点数组 + glBindBuffer(GL_ARRAY_BUFFER, VBO);//绑定顶点缓冲 + //指定顶点数组的数据源为vertices,第四个参数代表显卡如何管理给定的数据,GL_STATIC_DRWA代表几乎不会改变 + glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); + + // 指定顶点属性的解析方式。即,如何从顶点缓冲获取相应的顶点属性和相应的颜色属性。或者说,顶点着色器中如何知道去哪个顶点属性分量重着色呢 + //对每一个顶点而言,属性有2种,一是位置属性,而是颜色属性,因此每六个浮点数决定了一个顶点的位置和颜色 + + //顶点着色器中使用layout(location = 0)定义了position顶点属性的位置值(Location),因此第一个参数,代表属性分量的索引 + //参数二:顶点位置属性的维度,参数三:属性向量的数据类型,参数四:是否标准化;参数五,顶点位置属性的总字节长度,参数六:在缓冲数组中的偏移量,即起始位置 + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0); + glEnableVertexAttribArray(0);//启用属性0,因为默认是禁用的 + + // 参数一,对应顶点着色器中的layout (location = 1) in vec3 color;参数六:说明颜色属性的偏移量在三个浮点数后,与上文vertices一致 + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat))); + glEnableVertexAttribArray(1);//启用属性1. + + //顶点数组对象(Vertex Array Object, VAO)的好处就是,当配置顶点属性指针时,你只需要将上面的代码调用执行一次,之后再绘制物体的时候只需要绑定相应的VAO就行了。如下文循环中的绑定再解绑 + glBindVertexArray(0); // 解绑 VAO + // Game loop + while (!glfwWindowShouldClose(window)) + { + // 检查事件,调用相应的回调函数,如下文的key_callback函数 + glfwPollEvents(); + + // Render + // Clear the colorbuffer + glClearColor(0.2f, 0.3f, 0.3f, 1.0f);//渲染颜色到后台缓冲 + glClear(GL_COLOR_BUFFER_BIT);//清除前台缓冲 + + // Draw the triangle + ourShader.Use();//启用着色器程序 + glBindVertexArray(VAO);//每次循环都调用,绑定函数绑定VAO + glDrawArrays(GL_TRIANGLES, 0, 3); + glBindVertexArray(0);//解绑 + + // Swap the screen buffers + glfwSwapBuffers(window); + } + // Properly de-allocate all resources once they've outlived their purpose + glDeleteVertexArrays(1, &VAO); + glDeleteBuffers(1, &VBO); + // Terminate GLFW, clearing any resources allocated by GLFW. + glfwTerminate(); + return 0; +} + + +// Is called whenever a key is pressed/released via GLFW +void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode) +{ + if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS) + glfwSetWindowShouldClose(window, GL_TRUE); +} diff --git a/Templates/GLFW_shader.frag.txt b/Templates/GLFW_shader.frag.txt new file mode 100644 index 00000000..00bbbd11 --- /dev/null +++ b/Templates/GLFW_shader.frag.txt @@ -0,0 +1,8 @@ +#version 330 core +in vec3 ourColor; +out vec4 color; + +void main() +{ + color = vec4(ourColor, 1.0f); +} diff --git a/Templates/GLFW_shader.h.txt b/Templates/GLFW_shader.h.txt new file mode 100644 index 00000000..01387630 --- /dev/null +++ b/Templates/GLFW_shader.h.txt @@ -0,0 +1,98 @@ +#ifndef SHADER_H +#define SHADER_H + +#include +#include +#include +#include + +#include + +class Shader +{ +public: + GLuint Program; + // Constructor generates the shader on the fly + Shader(const GLchar* vertexPath, const GLchar* fragmentPath) + { + // 1. Retrieve the vertex/fragment source code from filePath + std::string vertexCode; + std::string fragmentCode; + std::ifstream vShaderFile; + std::ifstream fShaderFile; + // ensures ifstream objects can throw exceptions: + vShaderFile.exceptions(std::ifstream::badbit); + fShaderFile.exceptions(std::ifstream::badbit); + try + { + // Open files + vShaderFile.open(vertexPath); + fShaderFile.open(fragmentPath); + std::stringstream vShaderStream, fShaderStream; + // Read file's buffer contents into streams + vShaderStream << vShaderFile.rdbuf(); + fShaderStream << fShaderFile.rdbuf(); + // close file handlers + vShaderFile.close(); + fShaderFile.close(); + // Convert stream into string + vertexCode = vShaderStream.str(); + fragmentCode = fShaderStream.str(); + } + catch (std::ifstream::failure e) + { + std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl; + } + const GLchar* vShaderCode = vertexCode.c_str(); + const GLchar * fShaderCode = fragmentCode.c_str(); + // 2. Compile shaders + GLuint vertex, fragment; + GLint success; + GLchar infoLog[512]; + // Vertex Shader + vertex = glCreateShader(GL_VERTEX_SHADER);//创建顶点着色器 + glShaderSource(vertex, 1, &vShaderCode, NULL);//指定源代码 + glCompileShader(vertex);//编译着色器 + // Print compile errors if any + glGetShaderiv(vertex, GL_COMPILE_STATUS, &success);//查看是否编译成功 + if (!success) + { + glGetShaderInfoLog(vertex, 512, NULL, infoLog); + std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl; + } + // Fragment Shader + fragment = glCreateShader(GL_FRAGMENT_SHADER);//创建片段着色器 + glShaderSource(fragment, 1, &fShaderCode, NULL); + glCompileShader(fragment); + // Print compile errors if any + glGetShaderiv(fragment, GL_COMPILE_STATUS, &success); + if (!success) + { + glGetShaderInfoLog(fragment, 512, NULL, infoLog); + std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl; + } + // Shader Program + this->Program = glCreateProgram();//创建着色程序 + glAttachShader(this->Program, vertex);//关联顶点着色器 + glAttachShader(this->Program, fragment);//关联片段着色器 + glLinkProgram(this->Program);//链接编译器 + // Print linking errors if any + glGetProgramiv(this->Program, GL_LINK_STATUS, &success); + if (!success) + { + glGetProgramInfoLog(this->Program, 512, NULL, infoLog); + std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl; + } + // Delete the shaders as they're linked into our program now and no longer necessery + glDeleteShader(vertex); + glDeleteShader(fragment); + + } + // Uses the current shader + void Use() + { + glUseProgram(this->Program); + } +}; + +#endif diff --git a/Templates/GLFW_shader.vs.txt b/Templates/GLFW_shader.vs.txt new file mode 100644 index 00000000..b2141e1b --- /dev/null +++ b/Templates/GLFW_shader.vs.txt @@ -0,0 +1,11 @@ +#version 330 core +layout (location = 0) in vec3 position;//in 代表输入向量, location,与下面的顶点属性描述有关。 +layout (location = 1) in vec3 color; + +out vec3 ourColor;//out 代表输出3维向量,作为片段着色器的输入,见下文 + +void main() +{ + gl_Position = vec4(position, 1.0f); + ourColor = color; +} diff --git a/Templates/Games.ico b/Templates/Games.ico new file mode 100644 index 0000000000000000000000000000000000000000..1acc99dba73311f5949c7bdd05414f989ee8c870 GIT binary patch literal 6054 zcmeHL-**$o6&?c?u5d#IO_6ZHTg3rd;e=$tU??>N5djI18ZRcnG?2C{Cn@Gf3Tp?b z1thSR`4Li5SSO)PObS-O4u;sW74WJYT3U+=y3al*=k%OD`s6VWIc&c>yDP~?9RCB% z^6AdZz4yC!?vBKa87pApm>@97BBmEHHj6PfZ=OAVjIsY=ZVu*P!j=JKM=dge3+to6 z62qp-%poA9vLWhgfU2=r$^?d440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7mwnw zRv79q8eE2D5B8*fW8_iU%74wD|GF`>v36x>W#QKKMyF-Z*^z%Py#fB`U+Vbig;3$9 z_u99Cf7K^zFLC>Q$eo_t>YzTWKmKe>sBmRy(+3lT_AM(zq4U2qxc!b^oLnjY-kj4% z>)rMjDQmFfq*h81Uc7E}QvTq-LHX<1)3lM^w2E@J*eBrZM-l#!W~>%d)pu)LoE% zLTmWw5dVI~qc|(#N#?xaWVMs~tkdIs$8iLs9Yon%51oar7ByZ&-RbG@Ri2u^aKQrLW@DJX!BH3^f5I1zL-a1M zyCA&0yrAN+m*JUl7DssFZI{uI;SblR>;q-eW}k3jy022fscdPR(MUPRdmDJ})CcPS z#U1)>c477j9AXcbEb3OS&;{YahetSc-O3&BwQQWP^7m|^+SEe%<^gv|Zx%}Ft@{7u z^YQ$z&Aqxa4?D%H{|`!(-pnJsve*ZH)l@NCf8{ zP=pPK@op*q5_amTfE8iX8oK!XhF%&Xy!Qm|2v+@Pz8}aJ!C~hPM^1v>%Ab{JIMhF| zhRpjVd&8&zyOqC}{o*ZL0!FPNds*S;w}{=&zl2>aqFV#6lD&qmJ#=--wARJMZs*Uu z?~1U`jnMU0K*e1w+n%)fY5$b48E0^9aUx*ve6c4`^i0;+Fb<|a0OlPXe9jCS4e&-3R{&;0engTq+vv82R_U!IXkG`kCDVjcU%-a9V+s*lT zgswaP?w^*MOtyb8Y2`njDL;n;twFt)9x?mSjrpu;Zd(7}ZziwYOy*hR!(0yi@F7{_?^QZ$#%ESW?6D)6J+>uo zVBFr3-_ak6(7xsJYr0=yL=v~OymGufKU$KX4nL9+lFg%}qsP2%>$$A5$ECKMY)f1b zBV>m_Bq*VXEp=OdO%i(CEpglAtH6!Z#1$3|d{`yjI5X0jA1!%+W|J?N)=lLA4JWE1 TY3h91y13H#eieNZeZKa8q?h%} literal 0 HcmV?d00001 diff --git a/Templates/Hello.template b/Templates/Hello.template new file mode 100644 index 00000000..109c3e3d --- /dev/null +++ b/Templates/Hello.template @@ -0,0 +1,17 @@ +[Template] +ver=1 +Name=Hello World +Icon=Communication.ico +Description=A classic Hello World program +Category=Console + +[Unit0] +CName=main.c +CppName=main.cpp +C=Hello_c.txt +Cpp=Hello_cpp.txt + +[Project] +UnitCount=1 +Type=1 +Icon=Communication.ico diff --git a/Templates/HelloInput.template b/Templates/HelloInput.template new file mode 100644 index 00000000..dee27449 --- /dev/null +++ b/Templates/HelloInput.template @@ -0,0 +1,16 @@ +[Template] +ver=1 +Name=Input Loop +Icon=ConsoleToo.ico +Description=A console with an input loop +Category=Console + +[Unit0] +CName=main.c +CppName=main.c +C=HelloInput_c.txt +Cpp=HelloInput_cpp.txt + +[Project] +UnitCount=1 +Type=1 diff --git a/Templates/HelloInput_c.txt b/Templates/HelloInput_c.txt new file mode 100644 index 00000000..6e385c03 --- /dev/null +++ b/Templates/HelloInput_c.txt @@ -0,0 +1,27 @@ +#include + +void Foo() { + printf("Hello World!\n"); +} + +int main(int argc, char** argv) { + char input = 0; + + printf("Hello! This is a console application.\n"); + printf("Press q to quit, press a to execute foo.\n"); + while(1) { + if(scanf("%c",&input) == 1) { + if(input == 'a') { + Foo(); + } else if(input == 'q') { + break; + } else if(input != '\n') { + printf("Unknown command '%c'! Ignoring...\n",input); + } + } else { + printf("Invalid input! Ignoring...\n"); + } + } + + return 0; +} diff --git a/Templates/HelloInput_cpp.txt b/Templates/HelloInput_cpp.txt new file mode 100644 index 00000000..0cb67617 --- /dev/null +++ b/Templates/HelloInput_cpp.txt @@ -0,0 +1,27 @@ +#include +using std::cin; +using std::cout; +using std::endl; + +void Foo() { + cout << "Hello World!" << endl; +} + +int main(int argc, char** argv) { + char input = 0; + + cout << "Hello! This is a console application." << endl; + cout << "Press q to quit, press a to execute foo." << endl; + while(1) { + cin >> input; + if(input == 'a') { + Foo(); + } else if(input == 'q') { + break; + } else if(input != '\n') { + cout << "Unknown command '" << input << "'! Ignoring...\n"; + } + } + + return 0; +} diff --git a/Templates/Hello_c.txt b/Templates/Hello_c.txt new file mode 100644 index 00000000..015f3f20 --- /dev/null +++ b/Templates/Hello_c.txt @@ -0,0 +1,6 @@ +#include + +int main(int argc, char** argv) { + printf("Hello world!\n"); + return 0; +} \ No newline at end of file diff --git a/Templates/Hello_cpp.txt b/Templates/Hello_cpp.txt new file mode 100644 index 00000000..59205e45 --- /dev/null +++ b/Templates/Hello_cpp.txt @@ -0,0 +1,5 @@ +#include + +int main(int argc, char** argv) { + std::cout << "Hello world!\n"; +} \ No newline at end of file diff --git a/Templates/Jackpot.template b/Templates/Jackpot.template new file mode 100644 index 00000000..13b23d70 --- /dev/null +++ b/Templates/Jackpot.template @@ -0,0 +1,17 @@ +[Template] +ver=1 +Name=Jackpot +Icon=Games.ico +Description=A number guessing game +Category=Console + +[Unit0] +CName=main.c +CppName=main.cpp +C=Jackpot_c.txt +Cpp=Jackpot_cpp.txt + +[Project] +UnitCount=1 +Type=1 +Icon=Games.ico diff --git a/Templates/Jackpot_cpp.txt b/Templates/Jackpot_cpp.txt new file mode 100644 index 00000000..af939395 --- /dev/null +++ b/Templates/Jackpot_cpp.txt @@ -0,0 +1,88 @@ +#include +#include +#include + +using namespace std; + +void Start(); +void GetResults(); + +int i, j, life, maxrand; +char c; + +void Start() { + i = 0; + j = 0; + life = 0; + maxrand = 6; + + cout << "Select difficulty mode:\n"; // the user has to select a difficutly level + cout << "1 : Easy (0-15)\n"; + cout << "2 : Medium (0-30)\n"; + cout << "3 : Difficult (0-50)\n"; + cout << "or type another key to quit\n"; + c = 30; + + cin >> c; // read the user's choice + cout << "\n"; + + switch (c) { + case '1': + maxrand = 15; // the random number will be between 0 and maxrand + break; + case '2': + maxrand = 30; + break; + case '3': + maxrand = 50; + break; + default: + exit(0); + break; + } + + life = 5; // number of lifes of the player + srand((unsigned)time(NULL)); // init Rand() function + j = rand() % maxrand; // j get a random value between 0 and maxrand + + GetResults(); +} + +void GetResults() { + if (life <= 0) { // if player has no more life then he loses + cout << "You lose !\n\n"; + Start(); + } + + cout << "Type a number: \n"; + cin >> i; + + if((i>maxrand) || (i<0)) { // if the user number isn't correct, restart + cout << "Error: number not between 0 and \n" << maxrand; + GetResults(); + } + + if(i == j) { + cout << "YOU WIN!\n\n"; // the user found the secret number + Start(); + } else if(i>j) { + cout << "Too BIG\n"; + life = life - 1; + cout << "Lives remaining: " << life << "\n\n"; + GetResults(); + } else if(i +#include + +#include "main.h" + +LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT Message, WPARAM wParam,LPARAM lParam); + +char g_szAppName[] = "MyMDIWindow"; +char g_szChild[] = "MyMDIChild"; +HINSTANCE g_hInst; +HWND g_hMDIClient, g_hStatusBar, g_hToolBar; +HWND g_hMainWindow; + +BOOL LoadFile(HWND hEdit, LPSTR pszFileName) { + HANDLE hFile; + BOOL bSuccess = FALSE; + + hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); + if(hFile != INVALID_HANDLE_VALUE) { + DWORD dwFileSize; + dwFileSize = GetFileSize(hFile, NULL); + if(dwFileSize != 0xFFFFFFFF) { + LPSTR pszFileText; + pszFileText = (LPSTR)(GlobalAlloc(GPTR, dwFileSize + 1)); + if(pszFileText != NULL) { + DWORD dwRead; + if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL)) { + pszFileText[dwFileSize] = 0; // Null terminator + if(SetWindowText(hEdit, pszFileText)) + bSuccess = TRUE; // It worked! + } + GlobalFree(pszFileText); + } + } + CloseHandle(hFile); + } + return bSuccess; +} + +BOOL SaveFile(HWND hEdit, LPSTR pszFileName) { + HANDLE hFile; + BOOL bSuccess = FALSE; + + hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); + if(hFile != INVALID_HANDLE_VALUE) { + DWORD dwTextLength; + dwTextLength = GetWindowTextLength(hEdit); + if(dwTextLength > 0) {// No need to bother if there's no text. + LPSTR pszText; + pszText = (LPSTR)(GlobalAlloc(GPTR, dwTextLength + 1)); + if(pszText != NULL) { + if(GetWindowText(hEdit, pszText, dwTextLength + 1)) { + DWORD dwWritten; + if(WriteFile(hFile, pszText, dwTextLength, &dwWritten, NULL)) + bSuccess = TRUE; + } + GlobalFree(pszText); + } + } + CloseHandle(hFile); + } + return bSuccess; +} + +BOOL GetFileName(HWND hwnd, LPSTR pszFileName, BOOL bSave) { + OPENFILENAME ofn; + + ZeroMemory(&ofn, sizeof(ofn)); + pszFileName[0] = 0; + + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; + ofn.lpstrFile = pszFileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "txt"; + + if(bSave) { + ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | + OFN_OVERWRITEPROMPT; + if(!GetSaveFileName(&ofn)) + return FALSE; + } else { + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + if(!GetOpenFileName(&ofn)) + return FALSE; + } + return TRUE; +} + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpszCmdParam, int nCmdShow) { + MSG Msg; + WNDCLASSEX WndClassEx; + + g_hInst = hInstance; + + WndClassEx.cbSize = sizeof(WNDCLASSEX); + WndClassEx.style = CS_HREDRAW | CS_VREDRAW; + WndClassEx.lpfnWndProc = WndProc; + WndClassEx.cbClsExtra = 0; + WndClassEx.cbWndExtra = 0; + WndClassEx.hInstance = hInstance; + WndClassEx.hIcon = LoadIcon(NULL, IDI_APPLICATION); + WndClassEx.hCursor = LoadCursor(NULL, IDC_ARROW); + WndClassEx.hbrBackground = (HBRUSH)(COLOR_3DSHADOW+1); + WndClassEx.lpszMenuName = "MAIN"; + WndClassEx.lpszClassName = g_szAppName; + WndClassEx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + if(!RegisterClassEx(&WndClassEx)) { + MessageBox(0, "Could Not Register Window", "Oh Oh...",MB_ICONEXCLAMATION | MB_OK); + return -1; + } + + WndClassEx.lpfnWndProc = MDIChildWndProc; + WndClassEx.lpszMenuName = NULL; + WndClassEx.lpszClassName = g_szChild; + WndClassEx.hbrBackground = (HBRUSH)(COLOR_3DFACE+1); + + if(!RegisterClassEx(&WndClassEx)) { + MessageBox(0, "Could Not Register Child Window", "Oh Oh...", + MB_ICONEXCLAMATION | MB_OK); + return -1; + } + + g_hMainWindow = CreateWindowEx(WS_EX_APPWINDOW,g_szAppName,"MDI File Editor",WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + 0, 0, hInstance, NULL); + + if (g_hMainWindow == NULL){ + MessageBox(0, "No Window", "Oh Oh...", MB_ICONEXCLAMATION | MB_OK); + return -1; + } + + ShowWindow(g_hMainWindow, nCmdShow); + UpdateWindow(g_hMainWindow); + + while(GetMessage(&Msg, NULL, 0, 0)) { + if (!TranslateMDISysAccel(g_hMDIClient, &Msg)) { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + return Msg.wParam; +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { + switch(Message) { + case WM_CREATE: { + CLIENTCREATESTRUCT ccs; + int iStatusWidths[] = {200, 300, -1}; + TBADDBITMAP tbab; + TBBUTTON tbb[9]; + + // Find window menu where children will be listed + ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 2); + ccs.idFirstChild = ID_MDI_FIRSTCHILD; + g_hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE, "mdiclient", NULL, + WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hwnd, (HMENU)ID_MDI_CLIENT, g_hInst, (LPVOID)&ccs); + ShowWindow(g_hMDIClient, SW_SHOW); + + g_hStatusBar = CreateWindowEx(0, STATUSCLASSNAME, NULL, + WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, 0, 0, 0, 0, + hwnd, (HMENU)ID_STATUSBAR, g_hInst, NULL); + SendMessage(g_hStatusBar, SB_SETPARTS, 3, (LPARAM)iStatusWidths); + SendMessage(g_hStatusBar, SB_SETTEXT, 2, (LPARAM)"Toolbar & Statusbar Example"); + + g_hToolBar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, + WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, + hwnd, (HMENU)ID_TOOLBAR, g_hInst, NULL); + + // Send the TB_BUTTONSTRUCTSIZE message, which is required for + // backward compatibility. + SendMessage(g_hToolBar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0); + + tbab.hInst = HINST_COMMCTRL; + tbab.nID = IDB_STD_SMALL_COLOR; + SendMessage(g_hToolBar, TB_ADDBITMAP, 0, (LPARAM)&tbab); + + ZeroMemory(tbb, sizeof(tbb)); + + tbb[0].iBitmap = STD_FILENEW; + tbb[0].fsState = TBSTATE_ENABLED; + tbb[0].fsStyle = TBSTYLE_BUTTON; + tbb[0].idCommand = CM_FILE_NEW; + + tbb[1].iBitmap = STD_FILEOPEN; + tbb[1].fsState = TBSTATE_ENABLED; + tbb[1].fsStyle = TBSTYLE_BUTTON; + tbb[1].idCommand = CM_FILE_OPEN; + + tbb[2].iBitmap = STD_FILESAVE; + tbb[2].fsStyle = TBSTYLE_BUTTON; + tbb[2].idCommand = CM_FILE_SAVE; + + tbb[3].fsStyle = TBSTYLE_SEP; + + tbb[4].iBitmap = STD_CUT; + tbb[4].fsStyle = TBSTYLE_BUTTON; + tbb[4].idCommand = CM_EDIT_CUT; + + tbb[5].iBitmap = STD_COPY; + tbb[5].fsStyle = TBSTYLE_BUTTON; + tbb[5].idCommand = CM_EDIT_COPY; + + tbb[6].iBitmap = STD_PASTE; + tbb[6].fsStyle = TBSTYLE_BUTTON; + tbb[6].idCommand = CM_EDIT_PASTE; + + tbb[7].fsStyle = TBSTYLE_SEP; + + tbb[8].iBitmap = STD_UNDO; + tbb[8].fsStyle = TBSTYLE_BUTTON; + tbb[8].idCommand = CM_EDIT_UNDO; + + SendMessage(g_hToolBar, TB_ADDBUTTONS, 9, (LPARAM)&tbb); + return 0; + } + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case CM_FILE_EXIT: + PostMessage(hwnd, WM_CLOSE, 0, 0); + break; + case CM_FILE_NEW: { + MDICREATESTRUCT mcs; + HWND hChild; + + mcs.szTitle = "[Untitled]"; + mcs.szClass = g_szChild; + mcs.hOwner = g_hInst; + mcs.x = mcs.cx = CW_USEDEFAULT; + mcs.y = mcs.cy = CW_USEDEFAULT; + mcs.style = MDIS_ALLCHILDSTYLES; + + hChild = (HWND)SendMessage(g_hMDIClient, WM_MDICREATE,0, (LPARAM)&mcs); + if(!hChild) { + MessageBox(hwnd, "MDI Child creation failed.", "Oh Oh...",MB_ICONEXCLAMATION | MB_OK); + } + break; + } + case CM_FILE_OPEN: { + MDICREATESTRUCT mcs; + HWND hChild; + char szFileName[MAX_PATH]; + + if(!GetFileName(hwnd, szFileName, FALSE)) + break; + + mcs.szTitle = szFileName; + mcs.szClass = g_szChild; + mcs.hOwner = g_hInst; + mcs.x = mcs.cx = CW_USEDEFAULT; + mcs.y = mcs.cy = CW_USEDEFAULT; + mcs.style = MDIS_ALLCHILDSTYLES; + + hChild = (HWND)SendMessage(g_hMDIClient, WM_MDICREATE, 0, (LPARAM)&mcs); + + if(!hChild) { + MessageBox(hwnd, "MDI Child creation failed.", "Oh Oh...", + MB_ICONEXCLAMATION | MB_OK); + } + break; + } + case CM_WINDOW_TILEHORZ: + PostMessage(g_hMDIClient, WM_MDITILE, MDITILE_HORIZONTAL, 0); + break; + case CM_WINDOW_TILEVERT: + PostMessage(g_hMDIClient, WM_MDITILE, MDITILE_VERTICAL, 0); + break; + case CM_WINDOW_CASCADE: + PostMessage(g_hMDIClient, WM_MDICASCADE, 0, 0); + break; + case CM_WINDOW_ARRANGE: + PostMessage(g_hMDIClient, WM_MDIICONARRANGE, 0, 0); + break; + default: { + if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD){ + DefFrameProc(hwnd, g_hMDIClient, Message, wParam, lParam); + } else { + HWND hChild; + hChild = (HWND)SendMessage(g_hMDIClient, WM_MDIGETACTIVE,0,0); + if(hChild){ + SendMessage(hChild, WM_COMMAND, wParam, lParam); + } + } + } + } + break; + } + case WM_SIZE: { + RECT rectClient, rectStatus, rectTool; + UINT uToolHeight, uStatusHeight, uClientAlreaHeight; + + SendMessage(g_hToolBar, TB_AUTOSIZE, 0, 0); + SendMessage(g_hStatusBar, WM_SIZE, 0, 0); + + GetClientRect(hwnd, &rectClient); + GetWindowRect(g_hStatusBar, &rectStatus); + GetWindowRect(g_hToolBar, &rectTool); + + uToolHeight = rectTool.bottom - rectTool.top; + uStatusHeight = rectStatus.bottom - rectStatus.top; + uClientAlreaHeight = rectClient.bottom; + + MoveWindow(g_hMDIClient, 0, uToolHeight, rectClient.right, uClientAlreaHeight - uStatusHeight - uToolHeight, TRUE); + break; + } + case WM_CLOSE: + DestroyWindow(hwnd); + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefFrameProc(hwnd, g_hMDIClient, Message, wParam, lParam); + } + return 0; +} + +LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT Message, WPARAM wParam,LPARAM lParam) { + switch(Message) { + case WM_CREATE: { + char szFileName[MAX_PATH]; + HWND hEdit; + + hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + hwnd, (HMENU)IDC_CHILD_EDIT, g_hInst, NULL); + + SendMessage(hEdit, WM_SETFONT, + (WPARAM)GetStockObject(DEFAULT_GUI_FONT), MAKELPARAM(TRUE, 0)); + + GetWindowText(hwnd, szFileName, MAX_PATH); + if(*szFileName != '[') { + if(!LoadFile(hEdit, szFileName)) { + MessageBox(hwnd, "Couldn't Load File.", "Error.",MB_OK | MB_ICONEXCLAMATION); + return -1; //cancel window creation + } + } + break; + } + case WM_SIZE: + if(wParam != SIZE_MINIMIZED) + MoveWindow(GetDlgItem(hwnd, IDC_CHILD_EDIT), 0, 0, LOWORD(lParam),HIWORD(lParam), TRUE); + break; + case WM_MDIACTIVATE: { + HMENU hMenu, hFileMenu; + BOOL EnableFlag; + char szFileName[MAX_PATH]; + + hMenu = GetMenu(g_hMainWindow); + if(hwnd == (HWND)lParam){ //being activated + EnableFlag = TRUE; + } else{ + EnableFlag = FALSE; //being de-activated + } + EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hMenu, 2, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + + hFileMenu = GetSubMenu(hMenu, 0); + EnableMenuItem(hFileMenu, CM_FILE_SAVE, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hFileMenu, CM_FILE_SAVEAS, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + + DrawMenuBar(g_hMainWindow); + + SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_FILE_SAVE, MAKELONG(EnableFlag, 0)); + SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_UNDO, MAKELONG(EnableFlag, 0)); + SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_CUT, MAKELONG(EnableFlag, 0)); + SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_COPY, MAKELONG(EnableFlag, 0)); + SendMessage(g_hToolBar, TB_ENABLEBUTTON, CM_EDIT_PASTE, MAKELONG(EnableFlag, 0)); + + GetWindowText(hwnd, szFileName, MAX_PATH); + SendMessage(g_hStatusBar, SB_SETTEXT, 0, (LPARAM)(EnableFlag ? szFileName : "")); + break; + } + case WM_SETFOCUS: + SetFocus(GetDlgItem(hwnd, IDC_CHILD_EDIT)); + break; + case WM_COMMAND: { + switch(LOWORD(wParam)) { + case CM_FILE_SAVE: { + char szFileName[MAX_PATH]; + + GetWindowText(hwnd, szFileName, MAX_PATH); + if(*szFileName != '[') { + if(!SaveFile(GetDlgItem(hwnd, IDC_CHILD_EDIT), szFileName)) { + MessageBox(hwnd, "Couldn't Save File.", "Error.",MB_OK | MB_ICONEXCLAMATION); + return 0; + } + } else { + PostMessage(hwnd, WM_COMMAND,MAKEWPARAM(CM_FILE_SAVEAS, 0), 0); + } + return 0; + } + case CM_FILE_SAVEAS: { + char szFileName[MAX_PATH]; + + if(GetFileName(hwnd, szFileName, TRUE)) { + if(!SaveFile(GetDlgItem(hwnd, IDC_CHILD_EDIT), szFileName)) { + MessageBox(hwnd, "Couldn't Save File.", "Error.",MB_OK | MB_ICONEXCLAMATION); + return 0; + } else { + SetWindowText(hwnd, szFileName); + } + } + return 0; + } + case CM_EDIT_UNDO: + SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, EM_UNDO, 0, 0); + break; + case CM_EDIT_CUT: + SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_CUT, 0, 0); + break; + case CM_EDIT_COPY: + SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_COPY, 0, 0); + break; + case CM_EDIT_PASTE: + SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_PASTE, 0, 0); + break; + } + return 0; + } + } + return DefMDIChildProc(hwnd, Message, wParam, lParam); +} diff --git a/Templates/MDIEditor_h.txt b/Templates/MDIEditor_h.txt new file mode 100644 index 00000000..e033af66 --- /dev/null +++ b/Templates/MDIEditor_h.txt @@ -0,0 +1,24 @@ +#define CM_WINDOW_TILEVERT 9080 +#define CM_WINDOW_TILEHORZ 9082 +#define CM_WINDOW_ARRANGE 9081 +#define CM_WINDOW_TILE 9080 +#define CM_WINDOW_CASCADE 9076 +#define CM_EDIT_PASTE 9079 +#define CM_EDIT_COPY 9078 +#define CM_EDIT_CUT 9077 +#define CM_EDIT_REDO 9076 +#define CM_EDIT_UNDO 9075 +#define CM_FILE_SAVEAS 9074 +#define CM_FILE_SAVE 9073 +#define CM_FILE_OPEN 9072 +#define CM_HELP_ABOUT 9072 +#define CM_FILE_EXIT 9071 +#define CM_FILE_NEW 9070 + +#define ID_STATUSBAR 4997 +#define ID_TOOLBAR 4998 + +#define ID_MDI_CLIENT 4999 +#define ID_MDI_FIRSTCHILD 50000 + +#define IDC_CHILD_EDIT 2000 diff --git a/Templates/MDIEditor_rc.txt b/Templates/MDIEditor_rc.txt new file mode 100644 index 00000000..8428b5d3 --- /dev/null +++ b/Templates/MDIEditor_rc.txt @@ -0,0 +1,31 @@ +#include "main.h" + +MAIN MENU +{ + POPUP "&File" + { + MENUITEM "&New", CM_FILE_NEW + MENUITEM "&Open...", CM_FILE_OPEN + MENUITEM "&Save", CM_FILE_SAVE, GRAYED + MENUITEM "Save &As...", CM_FILE_SAVEAS, GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", CM_FILE_EXIT + } + + POPUP "&Edit", GRAYED + { + MENUITEM "&Undo\tCtrl+Z", CM_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", CM_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", CM_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", CM_EDIT_PASTE + } + + POPUP "&Window", GRAYED + { + MENUITEM "&Cascade", CM_WINDOW_CASCADE + MENUITEM "Tile &Horizontal", CM_WINDOW_TILEHORZ + MENUITEM "Tile &Vertical", CM_WINDOW_TILEVERT + MENUITEM "Arrange &Icons", CM_WINDOW_ARRANGE + } +} diff --git a/Templates/OpenGL.template b/Templates/OpenGL.template new file mode 100644 index 00000000..babfc42d --- /dev/null +++ b/Templates/OpenGL.template @@ -0,0 +1,17 @@ +[Template] +ver=1 +Name=OpenGL +Icon=Pizza.ico +Description=A basic OpenGL program +Category=Multimedia + +[Unit0] +CName=main.c +CppName=main.cpp +C=OpenGL.txt +Cpp=OpenGL.txt + +[Project] +UnitCount=1 +Type=0 +Linker=-lopengl32 diff --git a/Templates/OpenGL.txt b/Templates/OpenGL.txt new file mode 100644 index 00000000..58c1f1de --- /dev/null +++ b/Templates/OpenGL.txt @@ -0,0 +1,190 @@ +/************************** + * Includes + * + **************************/ + +#include +#include + + +/************************** + * Function Declarations + * + **************************/ + +LRESULT CALLBACK WndProc (HWND hWnd, UINT message, +WPARAM wParam, LPARAM lParam); +void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC); +void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC); + + +/************************** + * WinMain + * + **************************/ + +int WINAPI WinMain (HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int iCmdShow) +{ + WNDCLASS wc; + HWND hWnd; + HDC hDC; + HGLRC hRC; + MSG msg; + BOOL bQuit = FALSE; + float theta = 0.0f; + + /* register window class */ + wc.style = CS_OWNDC; + wc.lpfnWndProc = WndProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = hInstance; + wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); + wc.lpszMenuName = NULL; + wc.lpszClassName = "GLSample"; + RegisterClass (&wc); + + /* create main window */ + hWnd = CreateWindow ( + "GLSample", "OpenGL Sample", + WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE, + 0, 0, 256, 256, + NULL, NULL, hInstance, NULL); + + /* enable OpenGL for the window */ + EnableOpenGL (hWnd, &hDC, &hRC); + + /* program main loop */ + while (!bQuit) + { + /* check for messages */ + if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) + { + /* handle or dispatch messages */ + if (msg.message == WM_QUIT) + { + bQuit = TRUE; + } + else + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + } + else + { + /* OpenGL animation code goes here */ + + glClearColor (0.0f, 0.0f, 0.0f, 0.0f); + glClear (GL_COLOR_BUFFER_BIT); + + glPushMatrix (); + glRotatef (theta, 0.0f, 0.0f, 1.0f); + glBegin (GL_TRIANGLES); + glColor3f (1.0f, 0.0f, 0.0f); glVertex2f (0.0f, 1.0f); + glColor3f (0.0f, 1.0f, 0.0f); glVertex2f (0.87f, -0.5f); + glColor3f (0.0f, 0.0f, 1.0f); glVertex2f (-0.87f, -0.5f); + glEnd (); + glPopMatrix (); + + SwapBuffers (hDC); + + theta += 1.0f; + Sleep (1); + } + } + + /* shutdown OpenGL */ + DisableOpenGL (hWnd, hDC, hRC); + + /* destroy the window explicitly */ + DestroyWindow (hWnd); + + return msg.wParam; +} + + +/******************** + * Window Procedure + * + ********************/ + +LRESULT CALLBACK WndProc (HWND hWnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + + switch (message) + { + case WM_CREATE: + return 0; + case WM_CLOSE: + PostQuitMessage (0); + return 0; + + case WM_DESTROY: + return 0; + + case WM_KEYDOWN: + switch (wParam) + { + case VK_ESCAPE: + PostQuitMessage(0); + return 0; + } + return 0; + + default: + return DefWindowProc (hWnd, message, wParam, lParam); + } +} + + +/******************* + * Enable OpenGL + * + *******************/ + +void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC) +{ + PIXELFORMATDESCRIPTOR pfd; + int iFormat; + + /* get the device context (DC) */ + *hDC = GetDC (hWnd); + + /* set the pixel format for the DC */ + ZeroMemory (&pfd, sizeof (pfd)); + pfd.nSize = sizeof (pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | + PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 24; + pfd.cDepthBits = 16; + pfd.iLayerType = PFD_MAIN_PLANE; + iFormat = ChoosePixelFormat (*hDC, &pfd); + SetPixelFormat (*hDC, iFormat, &pfd); + + /* create and enable the render context (RC) */ + *hRC = wglCreateContext( *hDC ); + wglMakeCurrent( *hDC, *hRC ); + +} + + +/****************** + * Disable OpenGL + * + ******************/ + +void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC) +{ + wglMakeCurrent (NULL, NULL); + wglDeleteContext (hRC); + ReleaseDC (hWnd, hDC); +} diff --git a/Templates/OpenMP.template b/Templates/OpenMP.template new file mode 100644 index 00000000..138623d0 --- /dev/null +++ b/Templates/OpenMP.template @@ -0,0 +1,19 @@ +[Template] +ver=1 +Name=OpenMP +Icon=File Management.ico +Description=A OpenMP multithreading example +Category=Console + +[Unit0] +CName=main.c +CppName=main.cpp +C=OpenMP_c.txt +Cpp=OpenMP_cpp.txt + +[Project] +UnitCount=1 +Type=1 +Compiler=-fopenmp +CppCompiler=-fopenmp +Linker=-lgomp diff --git a/Templates/OpenMP_c.txt b/Templates/OpenMP_c.txt new file mode 100644 index 00000000..17d77efd --- /dev/null +++ b/Templates/OpenMP_c.txt @@ -0,0 +1,17 @@ +#include +#include + +int main() { + + int i; + + #pragma omp parallel num_threads(2) + printf("Hi, I'm thread number %d!\n",omp_get_thread_num()); + + #pragma omp parallel for num_threads(2) + for(i = 0;i < 20;i++) { + printf("\nThread number %d, executing iteration %d...",omp_get_thread_num(),i); + } + + return 0; +} diff --git a/Templates/OpenMP_cpp.txt b/Templates/OpenMP_cpp.txt new file mode 100644 index 00000000..44eff209 --- /dev/null +++ b/Templates/OpenMP_cpp.txt @@ -0,0 +1,26 @@ +#include +#include + +// not using iostream here due to output ordering issues + +// iostream tends to output each part between <<'s separately to the console, +// which can lead to random output if multiple threads are doing the same +// thing. + +// printf will generally output the whole result string in one go, so results +// of separate printf calls, even from different threads, will remain intact + +// Another fix, other than using printf, would be to give each thread its own +// place to store output temporarily (a stringstream), and then output the whole +// result in one go. + +int main() { + + #pragma omp parallel num_threads(2) + printf("Hi, I'm thread number %d!\n",omp_get_thread_num()); + + #pragma omp parallel for num_threads(2) + for(int i = 0;i < 20;i++) { + printf("\nThread number %d, executing iteration %d...",omp_get_thread_num(),i); + } +} \ No newline at end of file diff --git a/Templates/Pizza.ico b/Templates/Pizza.ico new file mode 100644 index 0000000000000000000000000000000000000000..a098ba12ca2c6e87f1b499f0c6af58976447d9de GIT binary patch literal 4286 zcmchZA&lcj6o$PzvT#ePMeT((Ffgc9NF_tVP(wpQldEKC>4?h=jzqd%&nhx>Rb*&r zXq5#9hTZG`O*}a#+S}c`UOUmt*yEY`|M$N)&klkc{a(Hd_z&LR1;MvL5d0w1Q1FwC zao48qbaVNCJRa@;GEz4nz7%tg`15n77J^d z1_{m_*6Xz$b&viB>~Q#ZracDv*bjpZGJ1Sw3@mis@Aqf?jd+30T(I|;o`0$JeQ!~? zvGrs{S{`q#$`fnr%DQ%Eb(vY7gqCjC z7H_u~_~;KNc(vk#7W9lc`wTsp4}K<`gVqgwXXV5rk3&nMwQaBPz5n2YO{}`Eb6R*k zoEFcC&4iDi+yne7Nf@vsj!8acSH3#6eis9L7<(Q{}c(zBwyW+sVj3#>+gl zO4@=+V}BYxxf-k(m;GpWiR$70XsI|vNovdGLV6S~cXGu94xP@5(_+rUpW#_g4LBT* z&JSuJ`F=t_;d71u4qq|Dr&TjpP!1M%qgBJ+ws~R6uCdi}X>q)Dc|kr<&xqGNCO(dH zZP*)M!KYp0pZ(W7G%Tvd7RypKE4E-=St%_#S(FyGQmtOAj%=c>tJ#@igOMBLEqj6E z@i{|qdJO;CfAp>U!OC54%S~fpx3{R@Tiom|Z%51P&a$GiTzH}C9r+4}Liero@b4PW z;aUDm7as%qPH_!3y`|&9mW8f!*;;(c(N^NKC_5_@r)>s@Q1K1VX9axX!g+B1KcPSV z)8_bt&Q6ll7OZ*;l1{j_-Nn*BS8l|;-D~`gK51>8x3-Kj#YXQwoiENU`9Y3yR-f`8 zp4a%Sp%$&O-r{<+cF;R4s}zILZl%j2YAh**EBviub63H$w%dEOqhvyZDc_z?6SA8Ri8_bmw7_LQ~rZ>LOsRcIGqQ0&G)Ih-b&>|CVk7MwX$wxwfkP^R5RFT zzJ|5W@t=7fAHKe(o@?y%&hhcs6Vr(!>wL=iZ%NOY9zL|k>fg2h-Ve`-dyMAC=Dm9` z{mnTr#5#C9hClb8YjOt-+oM+We%|Ts z<3HMXeq4hKAHTn!>G6Gxn8zH}c*94=x%awX@8kFLJ!?ESuJNB3_~*X&_}+gX2iAJ+ z8S@%5#=YO$?{nSz`S3)4xL?oV{u=+GIbS*kCf|%WAmQthwQD!f0O+#d++S!&HMOoU4J9{?&jUEf4+DVeE9j@?T6QY Ln0@~$2!8wrB`;Om literal 0 HcmV?d00001 diff --git a/Templates/Single Dialog Application.ico b/Templates/Single Dialog Application.ico new file mode 100644 index 0000000000000000000000000000000000000000..94551655313deeeb2ef369973a2f74d8b3dda9d1 GIT binary patch literal 766 zcmdr}xeb6Y3_K76P*JC347Q3p(uJ`y0D~|BojC&qmXIirC^+Z*o$@FKDq09FeS@V2 zIsiQx$bq!JAyK{aqbBM6!@M ZpKbASl=%T~$LGJ>S8vb0+wX5s-2ja_Vk`gv literal 0 HcmV?d00001 diff --git a/Templates/Single Dialog Application.project.ico b/Templates/Single Dialog Application.project.ico new file mode 100644 index 0000000000000000000000000000000000000000..94551655313deeeb2ef369973a2f74d8b3dda9d1 GIT binary patch literal 766 zcmdr}xeb6Y3_K76P*JC347Q3p(uJ`y0D~|BojC&qmXIirC^+Z*o$@FKDq09FeS@V2 zIsiQx$bq!JAyK{aqbBM6!@M ZpKbASl=%T~$LGJ>S8vb0+wX5s-2ja_Vk`gv literal 0 HcmV?d00001 diff --git a/Templates/Single Dialog Application.template b/Templates/Single Dialog Application.template new file mode 100644 index 00000000..951798d5 --- /dev/null +++ b/Templates/Single Dialog Application.template @@ -0,0 +1,28 @@ +[Template] +ver=1 +Name=Single Dialog Application +Icon=Single Dialog Application.ico +Description=An Appliction use a dialog as the main UI +Category=Win32 +[Unit0] +CName=main.c +C=Single_Dialog_Application_main.c.txt +[Unit1] +CName=resource.rc +C=Single_Dialog_Application_resource.rc.txt +[Unit2] +CName=resource.h +C=Single_Dialog_Application_resource.h.txt + +[Project] +UnitCount=3 +Type=0 +IsCpp=0 +Compiler= +CppCompiler= +Linker= +CompilerSettings=0000000000000000000000000 +CompilerSet=0 +IncludeVersionInfo=0 +SupportXPThemes=0 +Icon=Single Dialog Application.project.ico diff --git a/Templates/Single_Dialog_Application_main.c.txt b/Templates/Single_Dialog_Application_main.c.txt new file mode 100644 index 00000000..303c4562 --- /dev/null +++ b/Templates/Single_Dialog_Application_main.c.txt @@ -0,0 +1,42 @@ +#include +#include "resource.h" + +HINSTANCE hInst; + +LRESULT MainDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam); + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { + MSG msg; + HWND hMainDlg = NULL; + + hInst = hInstance; + hMainDlg = CreateDialog(hInstance, (LPCTSTR)IDD_MAIN_DIALOG, 0,(DLGPROC)MainDlgProc); + ShowWindow(hMainDlg, nCmdShow); + while (GetMessage(&msg, NULL, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return 0; +} + +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_CLOSE: + DestroyWindow(hDlg); + return TRUE; + case WM_DESTROY: + PostQuitMessage(0); + return TRUE; + }; + return FALSE;//返回FALSE给缺省对话框函数DefDlgProc(),表示没有处理本消息 +} diff --git a/Templates/Single_Dialog_Application_resource.h.txt b/Templates/Single_Dialog_Application_resource.h.txt new file mode 100644 index 00000000..099111ef --- /dev/null +++ b/Templates/Single_Dialog_Application_resource.h.txt @@ -0,0 +1,5 @@ +#ifndef IDC_STATIC +#define IDC_STATIC (-1) +#endif + +#define IDD_MAIN_DIALOG 101 \ No newline at end of file diff --git a/Templates/Single_Dialog_Application_resource.rc.txt b/Templates/Single_Dialog_Application_resource.rc.txt new file mode 100644 index 00000000..c36ab46b --- /dev/null +++ b/Templates/Single_Dialog_Application_resource.rc.txt @@ -0,0 +1,24 @@ +// Generated by ResEdit 1.6.5 +// Copyright (C) 2006-2015 +// http://www.resedit.net + +#include +#include +#include +#include "resource.h" + + + + +// +// Dialog resources +// +LANGUAGE 0, SUBLANG_NEUTRAL +IDD_MAIN_DIALOG DIALOG 0, 0, 186, 95 +STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "Ms Shell Dlg" +{ + PUSHBUTTON "Cancel", IDCANCEL, 129, 24, 50, 14, 0, WS_EX_LEFT + DEFPUSHBUTTON "OK", IDOK, 129, 7, 50, 14, 0, WS_EX_LEFT +} diff --git a/Templates/Software.ico b/Templates/Software.ico new file mode 100644 index 0000000000000000000000000000000000000000..283fe4e087bfd21e572c8487cd2aa953c126f721 GIT binary patch literal 10278 zcmeI2PiP#;6^EZJWv4?-WGmpy3|P@2v2V`y$$Rn|Uq$xfv-je@4VVzn91QA{H8%x? z82XZ3M6x15x%jNZEQB25-rQ_oVi*u)!8EK4JF8(6w(`AK-90@$J)_vk=CXP-)z$Ut z{rUB)>Z&&-i7d%Gvc7(adPQVeBodKJmwfxy5^Z=lZuoZmj>sp7t*;C6feZqXpZq}k z^Y#x#{_!K#_wD$5$Zv>T!zLG%>aqKIu+{$1upwzY8%1xwAM9v**Bir0 zZ1TI?xyfFv-Lm`3J4Qb*+7D8r|6TiUHGB1T-Jijd(!T|#-`_3pO`gXDHS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--- /dev/null +++ b/Templates/StdThread.template @@ -0,0 +1,19 @@ +[Template] +ver=1 +Name=std::thread +Icon=Software.ico +Description=A C++ multithreading example +Category=Console + +[Unit0] +CName=main.c +CppName=main.cpp +C=StdThread_c.txt +Cpp=StdThread_cpp.txt + +[Project] +UnitCount=1 +Type=1 +Compiler= +CppCompiler=-std=gnu++11 +Linker= diff --git a/Templates/StdThread_c.txt b/Templates/StdThread_c.txt new file mode 100644 index 00000000..2e5ed0fd --- /dev/null +++ b/Templates/StdThread_c.txt @@ -0,0 +1,2 @@ +// Please note that MinGW32 compilers currently do not support . Use MinGW64 builds like TDM-GCC instead. +// C does not support this magic ;) \ No newline at end of file diff --git a/Templates/StdThread_cpp.txt b/Templates/StdThread_cpp.txt new file mode 100644 index 00000000..6138bd5a --- /dev/null +++ b/Templates/StdThread_cpp.txt @@ -0,0 +1,43 @@ +// Please note that MinGW32 compilers currently do not support . Use MinGW64 builds like TDM-GCC instead. + +#include +using std::thread; +#include +using std::vector; +#include + +struct ThreadItem { + char* result; // could've used stringstream too, but don't like their syntax + thread worker; +}; + +void* ThreadFunction(char** result) { + *result = new char[256]; + snprintf(*result,256,"Hello World from thread ID %d", + std::this_thread::get_id()); +} + +int main() { + // Get the amount of "processing units" + int n = std::thread::hardware_concurrency(); + + // Create array of threads + vector threadlist; + threadlist.resize(n); + + // Spawn a thread for each core + for(int i = 0;i < n;i++) { + threadlist[i].worker = thread(ThreadFunction,&threadlist[i].result); // pass rand() as data argument + } + + // Wait for them all to finish + for(int i = 0;i < n;i++) { + threadlist[i].worker.join(); + } + + // Present their calculation results + printf("Results:\n"); + for(int i = 0;i < n;i++) { + printf("%s\n",threadlist[i].result); + } +} \ No newline at end of file diff --git a/Templates/WinAnim.template b/Templates/WinAnim.template new file mode 100644 index 00000000..dc61d4ab --- /dev/null +++ b/Templates/WinAnim.template @@ -0,0 +1,22 @@ +[Template] +ver=1 +Name=Animation Example +Icon=Windows.ico +Description=A Win32 painting example +Category=Win32 + +[Unit0] +CName=main.c +CppName=main.cpp +C=WinAnim_c.txt +Cpp=WinAnim_c.txt + +[Unit1] +CName=resource.rc +CppName=resource.rc +C=WinAnim_rc.txt +Cpp=WinAnim_rc.txt + +[Project] +UnitCount=2 +Type=0 diff --git a/Templates/WinAnim_c.txt b/Templates/WinAnim_c.txt new file mode 100644 index 00000000..78d5a151 --- /dev/null +++ b/Templates/WinAnim_c.txt @@ -0,0 +1,191 @@ +/* + Name: WinAnim + Author: Brook Miles + Description: Making an animation in windows +*/ + +#include + +static char g_szClassName[] = "MyWindowClass"; +static HINSTANCE g_hInst = NULL; + +const UINT idTimer1 = 1; +UINT nTimerDelay = 10; + +HBITMAP hbmBall, hbmMask; +BITMAP bm; + +int ballX, ballY; +int deltaX, deltaY; + +int deltaValue = 4; + +void EraseBall(HDC hdc) +{ + RECT rc; + rc.left = ballX; + rc.top = ballY; + rc.right = ballX + bm.bmWidth; + rc.bottom = ballY + bm.bmHeight; + FillRect(hdc, &rc, (HBRUSH)(COLOR_BTNFACE+1)); +} + +void DrawBall(HDC hdc) +{ + HDC hdcMemory; + hdcMemory = CreateCompatibleDC(hdc); + + SelectObject(hdcMemory, hbmMask); + BitBlt(hdc, ballX, ballY, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCAND); + + SelectObject(hdcMemory, hbmBall); + BitBlt(hdc, ballX, ballY, bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCPAINT); + + DeleteDC(hdcMemory); +} + +void UpdateBall(HWND hwnd) +{ + RECT rc; + GetClientRect(hwnd, &rc); + + ballX += deltaX; + ballY += deltaY; + + if(ballX < 0){ + ballX = 0; + deltaX = deltaValue; + } + else if(ballX + bm.bmWidth > rc.right){ + ballX = rc.right - bm.bmWidth; + deltaX = -deltaValue; + } + if(ballY < 0){ + ballY = 0; + deltaY = deltaValue; + } + else if(ballY + bm.bmHeight > rc.bottom){ + ballY = rc.bottom - bm.bmHeight; + deltaY = -deltaValue; + } +} + +LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) +{ + switch(Message) + { + case WM_CREATE: + hbmBall = LoadBitmap(g_hInst, "BALLBMP"); + hbmMask = LoadBitmap(g_hInst, "MASKBMP"); + if(!hbmBall || !hbmMask){ + MessageBox(hwnd, "Load of resources failed.", "Error", + MB_OK | MB_ICONEXCLAMATION); + return -1; + } + + GetObject(hbmBall, sizeof(bm), &bm); + SetTimer(hwnd, idTimer1, nTimerDelay, NULL); + + ballX = 0; + ballY = 0; + deltaX = deltaValue; + deltaY = deltaValue; + + break; + case WM_TIMER: + if(hbmBall && hbmMask) + { + HDC hdcWindow; + hdcWindow = GetDC(hwnd); + + EraseBall(hdcWindow); + UpdateBall(hwnd); + DrawBall(hdcWindow); + + ReleaseDC(hwnd, hdcWindow); + } + break; + case WM_PAINT: + if(hbmBall && hbmMask) + { + PAINTSTRUCT ps; + HDC hdcWindow; + hdcWindow = BeginPaint(hwnd, &ps); + + DrawBall(hdcWindow); + + EndPaint(hwnd, &ps); + } + break; + case WM_CLOSE: + DestroyWindow(hwnd); + break; + case WM_DESTROY: + KillTimer(hwnd, idTimer1); + + DeleteObject(hbmBall); + DeleteObject(hbmMask); + PostQuitMessage(0); + break; + default: + return DefWindowProc(hwnd, Message, wParam, lParam); + } + return 0; +} + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, + LPSTR lpCmdLine, int nCmdShow) +{ + WNDCLASSEX WndClass; + HWND hwnd; + MSG Msg; + + g_hInst = hInstance; + + WndClass.cbSize = sizeof(WNDCLASSEX); + WndClass.style = 0; + WndClass.lpfnWndProc = WndProc; + WndClass.cbClsExtra = 0; + WndClass.cbWndExtra = 0; + WndClass.hInstance = g_hInst; + WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); + WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); + WndClass.lpszMenuName = NULL; + WndClass.lpszClassName = g_szClassName; + WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + if(!RegisterClassEx(&WndClass)) + { + MessageBox(0, "Window Registration Failed!", "Error!", + MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); + return 0; + } + + hwnd = CreateWindowEx( + WS_EX_CLIENTEDGE, + g_szClassName, + "A Bitmap Program", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, 320, 240, + NULL, NULL, g_hInst, NULL); + + if(hwnd == NULL) + { + MessageBox(0, "Window Creation Failed!", "Error!", + MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL); + return 0; + } + + ShowWindow(hwnd, nCmdShow); + UpdateWindow(hwnd); + + while(GetMessage(&Msg, NULL, 0, 0)) + { + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + return Msg.wParam; +} + diff --git a/Templates/WinAnim_rc.txt b/Templates/WinAnim_rc.txt new file mode 100644 index 00000000..82988149 --- /dev/null +++ b/Templates/WinAnim_rc.txt @@ -0,0 +1,2 @@ +BALLBMP BITMAP "ball.bmp" // can be found in the Templates folder, please copy to the project folder +MASKBMP BITMAP "ballmask.bmp" // as above \ No newline at end of file diff --git a/Templates/WinApp_c.txt b/Templates/WinApp_c.txt new file mode 100644 index 00000000..7ed1bb93 --- /dev/null +++ b/Templates/WinApp_c.txt @@ -0,0 +1,66 @@ +#include + +/* This is where all the input to the window goes to */ +LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { + switch(Message) { + + /* Upon destruction, tell the main thread to stop */ + case WM_DESTROY: { + PostQuitMessage(0); + break; + } + + /* All other messages (a lot of them) are processed using default procedures */ + default: + return DefWindowProc(hwnd, Message, wParam, lParam); + } + return 0; +} + +/* The 'main' function of Win32 GUI programs: this is where execution starts */ +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + WNDCLASSEX wc; /* A properties struct of our window */ + HWND hwnd; /* A 'HANDLE', hence the H, or a pointer to our window */ + MSG msg; /* A temporary location for all messages */ + + /* zero out the struct and set the stuff we want to modify */ + memset(&wc,0,sizeof(wc)); + wc.cbSize = sizeof(WNDCLASSEX); + wc.lpfnWndProc = WndProc; /* This is where we will send messages to */ + wc.hInstance = hInstance; + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + + /* White, COLOR_WINDOW is just a #define for a system color, try Ctrl+Clicking it */ + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wc.lpszClassName = "WindowClass"; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); /* Load a standard icon */ + wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); /* use the name "A" to use the project icon */ + + if(!RegisterClassEx(&wc)) { + MessageBox(NULL, "Window Registration Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); + return 0; + } + + hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Caption",WS_VISIBLE|WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, /* x */ + CW_USEDEFAULT, /* y */ + 640, /* width */ + 480, /* height */ + NULL,NULL,hInstance,NULL); + + if(hwnd == NULL) { + MessageBox(NULL, "Window Creation Failed!","Error!",MB_ICONEXCLAMATION|MB_OK); + return 0; + } + + /* + This is the heart of our program where all input is processed and + sent to WndProc. Note that GetMessage blocks code flow until it receives something, so + this loop will not produce unreasonably high CPU usage + */ + while(GetMessage(&msg, NULL, 0, 0) > 0) { /* If no error is received... */ + TranslateMessage(&msg); /* Translate key codes to chars if present */ + DispatchMessage(&msg); /* Send it to WndProc */ + } + return msg.wParam; +} diff --git a/Templates/Windows.ico b/Templates/Windows.ico new file mode 100644 index 0000000000000000000000000000000000000000..b26825372ac48d8e51a3a08efc131094e5bf5638 GIT binary patch literal 4286 zcmeHJD{$LD5IrZLutvp!DKs?e7zzrS8X5|U1PE$cB6w6YC4z#U2@(`Ms3|janBjKc z*=t`Fog&F8$h4O{t?qoX;-ZMzcJ?3`D@pzYmQib{HxW<=8qcqfExJt`}!ua^zpyt7yi*BsXu%Pr)!0)%f7{r zyj@>%FTT(-mw#*wxAM31_wgfciP^PN`Nf~h-#-6RE7!W*xPLEx^a;HX;C<*q`y6Ax z@BE{$zW%rK*J(uCU~xedE+}5FDA@*-MQhT@h6>(OW-;yZl&T^lQ)&zFxAh19<^1>c z^jd#Ib+!8ghUcaRDrx}3HDc_6##|u!4PO}OW1HU>19}LZ8UpAEAi6f6&#ks$4jlz2 zxG{$EW1pNU#NP)w8`uL)hjv20Fn76q{I)oJ!QMVdJY5!CSjV}7wj&PAZPLyK{@wly zx33RwJYBr*8upIim$2LzZi(Zg@}myz8ceCf)coJ84`cW%))1Ygl}5 z@*(%|V_1Kn#qzsRc*WvegC7{8?Nj#Pdk^_x2(N3gjyn8J__*CT{nA^Pq1y=y;_^`o_oe8AU)$d+aKpO`AqDyQlEwPH*%#!X#fBK literal 0 HcmV?d00001 diff --git a/Templates/ball.bmp b/Templates/ball.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5ae93a40581986913d1b4c772b3aaff39479f41e GIT binary patch literal 630 zcmY+BJDS5V2!!SR_5h}&OS$Jrzt>6aD^OD9D!x`K=LbDP#un1RAR%%8fBdw>1N+Cg zjj^>~R$#JQ3at u@t)tIs%QzSQS^lMfN6)WK*-Q0XxtIxH9vaqJX8J8*5#ev?F?r*)7ck)@*(E{ literal 0 HcmV?d00001