Home > Back-end >  C window to create a button
C window to create a button

Time:11-29

I wrote a test button code:
 
#include
#include
using namespace std;
Int main ()
{
The HWND show;
The HWND button;
The button=CreateWindow (" button ", "OK," WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 10,10,100,100, show, nullptr,
(HINSTANCE) GetWindowLong (show, GWL_HINSTANCE), nullptr);
ShowWindow (button, SW_SHOWNORMAL);
return 0;
}

Why error:
72 C: \ Program Files \ Dev (x86) - Cpp \ MinGW64 \ x86_64 - w64 - mingw32 \ include \ Windows h In the file included the from C:/Program Files (x86)/Dev Cpp/MinGW64/x86_64 - w64 - mingw32/include/Windows. H
1 E: \ \ VS_2019_C private information + + small game development \ \ demining stand-alone version. CPP the from E: \ \ private information VS_2019_C + + small game development \ \ demining stand-alone version. CPP
E: \ \ VS_2019_C private information + + small game development \ \ demining stand-alone version. CPP In function 'int main ()' :
83 34 E: \ \ private information VS_2019_C + + small game development \ \ demining stand-alone version. CPP [Error] 'GWL_HINSTANCE' was not declared in this scope
?????
What's the matter???????????

CodePudding user response:

The main function, to winmain function, is the window type program entrance,
Advice to see "Windows programming" this book, there are detailed explanations,

Your this kind of writing, similar to QT, or see QT learning materials can also be directly,

CodePudding user response:

reference 1st floor zjq9931 response:
the main function, to winmain function, is the window type program entrance,
Advice to see "Windows programming" this book, there are detailed explanations,

Your this kind of writing, similar to QT, or see QT learning materials can also directly,
eldest brother, you make the QT, can you tell me how to set the PlainTextEdit Tab indent length is 4?

CodePudding user response:

To see if a head file did not define, 64 macro definition slightly changed, check the header file have a 64 - bit instead of macro
You can refer to the following link
https://blog.csdn.net/iMatt/article/details/84349578

CodePudding user response:

reference written on the second floor. The code response:
Quote: refer to 1st floor zjq9931 response:
the main function, to winmain function, is the window type program entrance,
Advice to see "Windows programming" this book, there are detailed explanations,

Your this kind of writing, similar to QT, or see QT learning materials can also directly,
eldest brother, you make the QT, can you tell me how to set the PlainTextEdit Tab indent length is 4?

Like this, don't have the environment there is no way to verify
SetTabStopWidth ()
Some font is wider, not sure how should guarantee the width,
QT with much, may say is wrong,

CodePudding user response:


The main console can also create window, dllmain can also create a window,

CodePudding user response:

reference 5 floor smwhotjay reply:

The main console can also create window, dllmain can also create Windows,

Can be, but that is not suitable for beginners,

CodePudding user response:

Personal think the way the SDK pure API writing Windows programs have been out of date, efficiency is too low, it is ok to understand the principle, main is message mechanism,

A graphical user interface (GUI) programming can learn c + + Builder, advanced architecture (and c # drag controls), introduction to more easily,

C + + Builder is a real visual Development tool, c + + Builder can use the mouse to drag controls followed by a "design" set properties of a graphical user interface of the program, using the visual components/controls like "building blocks", built in the form of "wysiwyg" Application interface, which is the name of c + + Builder in the concept of the Builder, in this way, only needs to be written in c + + language business logic code, similar to the text interface programming under DOS, just concentrate on the business logic function, the code is very concise, data input and performance, in a graphical user interface, intuitive, and easy to use, this is RAD (Rapid Application Development, Rapid Application Development),

Book recommendation:
"C + + Builder 6 program design course (second edition)" (such as loyal lu, wen-liang liu/2011-04-01/science press) (dangdang)
"C + + Builder 6 programming examples of fine solution" (Zhao Mingxian), PDF, is a digital version, a scan version, there is also a complete implementation of tetris game,
"Wonderful" c + + Builder 6 programming Wu Yixian (Taiwan), there are a few simple little game, 10 can read later rewrite, is their mastery of the,
"C + + Builder 5 senior programming examples of fine solution" (written by Liu Bin) are larger practical program,

C + + Builder 6.0 several sample program project source code download:






C + + Builder first program (analog chat room) v1.11
C + + Builder analog to digital double clock sample (unfinished) v0.2.1
C + + Builder card game Demo v0.03
C + + Builder of irregular image transparent texture (transparent display bitmap) three methods and simple animation v1.3
Written by c + + Builder "ZEC, arithmetic exercise program" sea starfish scene v0.9.2
C + + Builder simple example phone book Demo v1.11

CodePudding user response:

Use MFC, wysiwyg, drag and drop controls directly, is very simple

CodePudding user response:

reference qybao reply: 3/f
to see if a head file did not define, 64 macro definition slightly changed, check the header file have a 64 - bit instead of macro
You can refer to the following link
https://blog.csdn.net/iMatt/article/details/84349578

I watched
Have a defined
 
# define GWL_HINSTANCE (-- 6)

CodePudding user response:

references 9 f abcd7038 response:
Quote: reference qybao reply: 3/f
to see if a head file did not define, 64 macro definition slightly changed, check the header file have a 64 - bit instead of macro
You can refer to the following link
https://blog.csdn.net/iMatt/article/details/84349578

I watched
Have a defined
 
# define GWL_HINSTANCE (-- 6)
whether the macro definition in # ifdef or # # ifndef, do you want to take a look at content does not meet the conditionsnullnullnullnullnullnullnullnullnullnullnullnull
  • Related