Convert a string to DWORD
-
Hello, I am pretty new to Win32 programming. How do I convert a string to a DWORD? For example, I want to convert this value: char *String = "WS_MAXIMIZE"; into a DWORD value. After the conversion, the String should be equal to WindowStyle ( see below ) char *String = "WS_MAXIMIZE"; DWORD WindowStyle = WS_MAXIMIZE; Here are the correct numeric values: String = 0x0046c104 WindowStyle = 16777216 I tried type casting: char *String = "WS_MAXIMIZE"; DWORD WindowStyle = (DWORD)String; But that made WindowStyle = 9093936 and that's not what I want. Please tell me how to convert a string (hexadecimal) to a double word. Thank You.
-
Hello, I am pretty new to Win32 programming. How do I convert a string to a DWORD? For example, I want to convert this value: char *String = "WS_MAXIMIZE"; into a DWORD value. After the conversion, the String should be equal to WindowStyle ( see below ) char *String = "WS_MAXIMIZE"; DWORD WindowStyle = WS_MAXIMIZE; Here are the correct numeric values: String = 0x0046c104 WindowStyle = 16777216 I tried type casting: char *String = "WS_MAXIMIZE"; DWORD WindowStyle = (DWORD)String; But that made WindowStyle = 9093936 and that's not what I want. Please tell me how to convert a string (hexadecimal) to a double word. Thank You.
Hi atol converts a string to a double. char *String="16777216"; DWORD num=atol(String); I dont think you will be able to convert "WS_MAXIMIZE" to the appropriate number anyway. WS_MAXIMIZE is a macro and macros within "" are not replaced. Regards The Best Relligion is Science. Once you understand it, you will know God.
-
Hello, I am pretty new to Win32 programming. How do I convert a string to a DWORD? For example, I want to convert this value: char *String = "WS_MAXIMIZE"; into a DWORD value. After the conversion, the String should be equal to WindowStyle ( see below ) char *String = "WS_MAXIMIZE"; DWORD WindowStyle = WS_MAXIMIZE; Here are the correct numeric values: String = 0x0046c104 WindowStyle = 16777216 I tried type casting: char *String = "WS_MAXIMIZE"; DWORD WindowStyle = (DWORD)String; But that made WindowStyle = 9093936 and that's not what I want. Please tell me how to convert a string (hexadecimal) to a double word. Thank You.
-
Hello, I am pretty new to Win32 programming. How do I convert a string to a DWORD? For example, I want to convert this value: char *String = "WS_MAXIMIZE"; into a DWORD value. After the conversion, the String should be equal to WindowStyle ( see below ) char *String = "WS_MAXIMIZE"; DWORD WindowStyle = WS_MAXIMIZE; Here are the correct numeric values: String = 0x0046c104 WindowStyle = 16777216 I tried type casting: char *String = "WS_MAXIMIZE"; DWORD WindowStyle = (DWORD)String; But that made WindowStyle = 9093936 and that's not what I want. Please tell me how to convert a string (hexadecimal) to a double word. Thank You.
WM_MAXIMIZE is a MACRO!!!! Only the compiler can convert it to the number it stands for. Convert a string run-time to the value the software has to know the value. you could build an array to map these macro strings to their appropriate number. Don't try it, just do it! ;-)
-
WM_MAXIMIZE is a MACRO!!!! Only the compiler can convert it to the number it stands for. Convert a string run-time to the value the software has to know the value. you could build an array to map these macro strings to their appropriate number. Don't try it, just do it! ;-)
Well I have a configuration text file that I read in when the app starts. I am using it so I can make easy changes without recompiling and to give to other developers so they can configure the display the way they want to... So I guess that's what I have to do since they are macros, huh? I'll just read the strings and compare them to an array of known macros and if they are the same I will set them accordingly. Any other suggestions or ideas will be appreciated. Thanks
-
Hello, I am pretty new to Win32 programming. How do I convert a string to a DWORD? For example, I want to convert this value: char *String = "WS_MAXIMIZE"; into a DWORD value. After the conversion, the String should be equal to WindowStyle ( see below ) char *String = "WS_MAXIMIZE"; DWORD WindowStyle = WS_MAXIMIZE; Here are the correct numeric values: String = 0x0046c104 WindowStyle = 16777216 I tried type casting: char *String = "WS_MAXIMIZE"; DWORD WindowStyle = (DWORD)String; But that made WindowStyle = 9093936 and that's not what I want. Please tell me how to convert a string (hexadecimal) to a double word. Thank You.
Hi Buddie, I think you have to go for Comparison for performing above task.
like this way char *String = "WS_MAXIMIZE"; DWORD WindowStyle; if(strcmp(String ,"WS_MAXIMIZE")==0) WindowStyle = WS_MAXIMIZE;
May be that would be right approach for solving this tyoe of problem. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk -
Hi Buddie, I think you have to go for Comparison for performing above task.
like this way char *String = "WS_MAXIMIZE"; DWORD WindowStyle; if(strcmp(String ,"WS_MAXIMIZE")==0) WindowStyle = WS_MAXIMIZE;
May be that would be right approach for solving this tyoe of problem. ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk -
WM_MAXIMIZE is a MACRO!!!! Only the compiler can convert it to the number it stands for. Convert a string run-time to the value the software has to know the value. you could build an array to map these macro strings to their appropriate number. Don't try it, just do it! ;-)
Despite the fact that WM_MAXIMIZE is a macro... If I set: DWORD test = 30343168; then the numerical value works the same with CreateWindow() as when I use: test = WS_MAXIMIZE|WS_OVERLAPPEDWINDOW; Is there no way to compute this numerical value without a compiler? Is this hex converted to binary then to numeric form?
-
Iceberg76 wrote: Thank You! it very nice Hear Thanks :) ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk