- SetWindowLongA function (winuser.h)
- Syntax
- Parameters
- Return value
- Remarks
- Examples
- Long long int on 32 bit machines
- 5 Answers 5
- Not the answer you’re looking for? Browse other questions tagged c++ c types or ask your own question.
- Linked
- Related
- Hot Network Questions
- Subscribe to RSS
- 32-битная vs 64-битная Windows. Что выбрать?
- Разрядность? What is it!
- Возвращаясь к Windows
- Что выбрать по итогу
- Windows Data Types
SetWindowLongA function (winuser.h)
Changes an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset into the extra window memory.
Syntax
Parameters
A handle to the window and, indirectly, the class to which the window belongs.
The zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of an integer. To set any other value, specify one of the following values.
Value | Meaning | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
GWL_EXSTYLE -20 | Sets a new extended window style. | ||||||||||||||||||||||||||||||||||||||||||||||||||
GWL_HINSTANCE -6 | Sets a new application instance handle. | ||||||||||||||||||||||||||||||||||||||||||||||||||
GWL_ID -12 | Sets a new identifier of the child window. The window cannot be a top-level window. | ||||||||||||||||||||||||||||||||||||||||||||||||||
GWL_STYLE -16 | Sets a new window style. | ||||||||||||||||||||||||||||||||||||||||||||||||||
GWL_USERDATA -21 | Sets the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero. | ||||||||||||||||||||||||||||||||||||||||||||||||||
GWL_WNDPROC -4 | Sets a new address for the window procedure. You cannot change this attribute if the window does not belong to the same process as the calling thread. The following values are also available when the hWnd parameter identifies a dialog box.
The replacement value. Return valueIf the function succeeds, the return value is the previous value of the specified 32-bit integer. If the function fails, the return value is zero. To get extended error information, call GetLastError. If the previous value of the specified 32-bit integer is zero, and the function succeeds, the return value is zero, but the function does not clear the last error information. This makes it difficult to determine success or failure. To deal with this, you should clear the last error information by calling SetLastError with 0 before calling SetWindowLong. Then, function failure will be indicated by a return value of zero and a GetLastError result that is nonzero. RemarksCertain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly. If you use SetWindowLong with the GWL_WNDPROC index to replace the window procedure, the window procedure must conform to the guidelines specified in the description of the WindowProc callback function. If you use SetWindowLong with the DWL_MSGRESULT index to set the return value for a message processed by a dialog procedure, you should return TRUE directly afterward. Otherwise, if you call any function that results in your dialog procedure receiving a window message, the nested window message could overwrite the return value you set using DWL_MSGRESULT. Calling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLong function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures. Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function. You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function. If the window has a class style of CS_CLASSDC or CS_OWNDC, do not set the extended window styles WS_EX_COMPOSITED or WS_EX_LAYERED. Calling SetWindowLong to set the style on a progressbar will reset its position. ExamplesThe winuser.h header defines SetWindowLong as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes. Long long int on 32 bit machinesvery simple question, I read that GCC supports long long int type. But how can make math operations with it, when CPU is 32 bit wide only? 5 Answers 5The compiler will synthesize math operations (or use function calls) that use more than one CPU instruction to perform the operation. For example, an add operation will add the low order components (the low words) of the long long values and will then take the carry out of that operation and feed it into an add operation on the high order words of the long long . So the following C code: might be represented by an instruction sequence that looks something like: And if you consider for a moment, compilers for 8 and 16 bits systems had to do this type of thing for 16 and/or 32-bit values long before long long came into being. Internally, the type is represented by a high-word and a low-word, like: The compiler needs to know if it is a 32bit or 64bit environment and then selects the right reprenstations of the number — if it is 64bit, it can be done natively, if it is 32bit, the compiler has to take care of the math between the high/lowword. If you have a look in math.h, you can see the functions used for this, and use them yourself. On an additional note, be aware of the difference between little-endian and big-endian (see wiki), the usage depends on the operating system. Saying an architecture is 32 bit (or 64 or whatever) is usually only an approximation of what the processor is capable of. Usually you only refer to the width of pointers with that number, arithmetic might be quite different. E.g the x86 architecture has 32 bit pointers, most arithmetic is performed in 32 bit registers, but it also has native support for some basic 64 bit operations. Also you shouldn’t follow the impression that the standard integer types have some prescribed width. In particular long long is at least 64 bit but may be wider. Use the typedefs int32_t, int64_t if you want to be portably sure about the width. If you want to know what gcc (or any other compiler) does with long long you have to look into the specification for your particular target platform It’s easy enough to just compile and test if you have a 32-bit system accessible. gcc has a flag -S which turns on assembly language output. Here’s what it produces on my 32-bit intel: Most likely as a class, not natively. same way any compiler can/could support any large number set. Not the answer you’re looking for? Browse other questions tagged c++ c types or ask your own question.LinkedRelatedHot Network QuestionsSubscribe to RSSTo subscribe to this RSS feed, copy and paste this URL into your RSS reader. site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.4.16.39093 By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. 32-битная vs 64-битная Windows. Что выбрать?Для многих всё ещё остаётся открытым вопрос, что такое разрядность системы и причём тут 32 и 64 бита. В этой статье разберёмся в этом вопросе. Поехали! Разрядность? What is it!Выбор 32 битной и 64 битной Windows напрямую связан с вопрос о разрядности процессора. Что же это такое? Разрядность — количество битов (разрядов) данных, одновременно обрабатываемых устройством за 1 такт, в нашем случае в качестве такого устройства выступает процессор. Процессор постоянно обменивается данными с оперативной памятью, поэтому от разрядности зависит сколько данных за 1 такт будет передано в оперативную память. Несколько трюков с арифметикой. Имеем обычный 32-разрядный процессор (какой-нибудь AMD Sempron 2004 года). Он может одновременно передать 2 ^ 32 = 4 294 967 296 бита = 4 Гб. Отсюда следует простой вывод, что будь у вас хоть 32 Гб оперативной памяти, процессор физически не может оперировать таким количеством информации. Ну ладно, сейчас на дворе уже 2019 год, в основном у всех 64-разрядные процессоры. А на что способны они? — Считаем. 2 ^ 18 446 744 073 709 551 616 бит = 16 Еб (16 * 1024 Тб) В общем это огромный объём данных, которой в ближайшие лет 100 вряд ли будет задействован. К тому же это теоретический предел, на деле более реальны цифры в терабайты (что-то около 16 Тб), что всё равно чертовски много. Кстати, чтобы определить разрядность вашего процессора, достаточно зайти в свойства системы и обратить внимание на эту строку (выделена на картинке ниже). 32-разрядная архитектура обозначается как x86, 64-разрядная — как x64. Также данная инфа есть на сайте производителя или на странице в магазине (обычно записи остаются). Там обаятельно указывается о поддержке 64 битных инструкций. Возвращаясь к WindowsРазрядность должна поддерживаться не только на аппаратном уровне, но и на программном. Поэтому выпускается 2 версии Windows: 32-битная и 64-битная. Думаю эти названия полностью отражает суть версий систем. 32-битная Windows умеет работать с 4 Гб оперативной памяти максимум. На деле всё несколько хуже, обычно доступно примерно 3,5 Гб. Стоит заметить, что имея 64-разрядный процессор, вы можете поставить Win32bit и получить всё тот же обрезок в 3,5Гб, но наоборот уже не получится. 64-битная Windows поддерживает более 4 Гб. Максимум в разных версиях Windows разный. Приведу официальные цифры для наиболее популярных сейчас систем.
Как вы могли заметить, владельцам данных систем вообще можно не парится об ограничениях на объём оперативки. Весь остальной софт аналогично делится на 2 категории: для 32-битных систем и для 64-битных систем.
Что выбрать по итогуА теперь пришло время ответить на самый главный вопрос, какую версию Windows выбрать. Есть несколько вариантов: Если у вас 32-разрядный процессор или меньше 2 ГБ ОЗУ, то выбора нет: на вашей системе нормально будет работать только 32-битная ОС. Если у вас 64-разрядный процессор и от 2 ГБ ОЗУ, устанавливайте 64-разрядную версию Windows как более современную и эффективную. Ещё небольшой момент. Он касается перехода с версии на версию. Предположим у вас 64-битный процессор, но установлена 32-битная Windows (странно конечно, но всё таки). В таком случае вам придётся выполнить чистую установку Windows с 64-битного образа. На этом у меня всё. Надеюсь данная статья была вам полезна и интересна.
Windows Data TypesThe data types supported by Windows are used to define function return values, function and message parameters, and structure members. They define the size and meaning of these elements. For more information about the underlying C/C++ data types, see Data Type Ranges. The following table contains the following types: character, integer, Boolean, pointer, and handle. The character, integer, and Boolean types are common to most C compilers. Most of the pointer-type names begin with a prefix of P or LP. Handles refer to a resource that has been loaded into memory. For more information about handling 64-bit integers, see Large Integers.
|