|
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.
|
|
|
|
|
What are you trying to achieve ? I can't see any point in
Iceberg76 wrote:
char *String = "WS_MAXIMIZE";
Are you storing some data in a CListCtrl or TreeCtrl ? Or playing with the registry ?
~RaGE();
|
|
|
|
|
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
|
|
|
|
|
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?
|
|
|
|
|
Hi Buddie,
I think you have to go for Comparison for performing above task.
like this way <br />
char *String = "WS_MAXIMIZE";<br />
DWORD WindowStyle;<br />
<br />
if(strcmp(String ,"WS_MAXIMIZE")==0)<br />
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
|
|
|
|
|
|
Iceberg76 wrote:
Thank You!
it very nice Hear Thanks
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
hi all,
I already created a Application using MFC,Visual C++6. Now I want to create a Web Interface that runs on Web-Server and users access it via WebBrouser....SO How do I create Such Web Interface...What is the easiest way to do it?...Is there a Componenet to convert Application to Web Interfaces?.
Any One know this,..please reply me soon..
Thanks in advance..
|
|
|
|
|
Nothing will do this for you - the easiest way is ASP.NET (VC#7)
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
HI ,
In SDI application , where can i check the Open Handler Function is written .
That is by Default in Menu File->Open.
thanx
Regards.
|
|
|
|
|
I think you are looking for -
CDocument class member function
virtual BOOL OnOpenDocument()
-------------------------
Have a great day ahead!
Regards,
Sohail Kadiwala
(My COM Blog - http://lovecom.blogspot.com)
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Hello Friends,
I am using CListView in my project where I am loading few images from specified path and just below each image I am displaying some text description which is different for all the images.
My problem lies in selection part.
Whenever I select any image either by clicking or by using the arrow keys, the image is getting selected with some blue shade giving an indication of selection, which I don't want it. I had even tried disabling the properites LVS_SELECTED and LVS_SHOWSELALWAYS, but with that one I am not able to retrieve the index of the image.
please help me in solving the problem for the selection of the item in the list control.
Thank you in advance,
Neelesh K J Jain.
|
|
|
|
|
i all,if i want to write a program to close an running application in Windows,what should i do,help me plz!
tien mkjerhk wjh
|
|
|
|
|
Hi,
Get the handle of the running application using FindWindow function and send the WM_CLOSE message using SendMessage
like SendMessage(hWnd,WM_CLOSE,0,0);
Hope this will help you
Sujan
|
|
|
|
|
Is #pragma once needed to be included in header files when writing pure ANSI C/C++? I know that managed code takes pragma once instead of conventional #ifndef, #define and #endif.
The problem is, managed code usually is compiled in Microsoft compiler, so writing #pragma once is no problem.
But when writing ANSI C/C++, one concern is portability, I write ANSI C/C++ code in Microsoft compiler, then I may distribute the code online. Other people may not use Microsoft compiler, and the compiler that they are using may not support #pragma once.
So, do I need to include #pragma once in header files when writing pure ANSI C/C++ code, or do you recommend doing so?
Thanks.
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
#pragma once is a Microsoft specific pragma; and not limited to Managed code ( it works for normal C++ code )
Is you intend to distribute your code online and might be compile on non microsoft compiler, you'd better use the #define #ifndef #endif .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
What the other guy said....
If your code might someday run on something other than Windows, you should not use #pragma once.
do this instead:
#ifndef HEADER_H /* this file is header.h */
#define HEADER_H
/* your code here */
#endif /* everthing between the ifndef and here is only done once */
|
|
|
|
|
Hello all!
I've racked my brains on this problem, and have now turned to those who know more than I for some solutions. I am creating an ISAPI Extension to generate GIF images and save them in my /images folder so that my site has immediate access to them. The reason I am using an ISAPI Extension is so that I can administer my website 100% via the web, but the site is heavily graphics dependent. I turned to the CxImage library for its support for saving GIF images, but I am having problems drawing. In a test program that I am using to test CxImage's functionality in this project, I am having some problems drawing. Here is a code sample:
<br />
void CImageGeneratorDlg::OnButton1() <br />
{<br />
<br />
CxIOFile ioFile;<br />
CString fileName;<br />
m_cEdit.GetWindowText(fileName);<br />
<br />
ioFile.Open(fileName, "wb");<br />
<br />
CxImage* generatedImg = GenerateImage();<br />
CxImage* images[] = { generatedImg };<br />
<br />
<br />
generatedImg->DecreaseBpp(8,0,0);<br />
<br />
long idx = generatedImg->GetPixelIndex(0,0);<br />
generatedImg->SetTransIndex(idx);<br />
generatedImg->SetPaletteColor(idx+1, RGB(255,0,255));<br />
<br />
CxImageGIF imageGIF;<br />
imageGIF.SetComment(_T("test"));<br />
<br />
imageGIF.Encode(&ioFile, images, 1);<br />
<br />
ioFile.Close();<br />
}<br />
<br />
CxImage* CImageGeneratorDlg::GenerateImage()<br />
{<br />
CxImage* img = new CxImage(50,100,24);<br />
<br />
if(!img) {<br />
TRACE("==>Could not create image");<br />
return NULL;<br />
}<br />
<br />
img->Clear();<br />
<br />
<br />
<br />
CDC screenDC;<br />
if(!screenDC.CreateDC("DISPLAY", NULL, NULL, NULL)) {<br />
MessageBox("Error");<br />
return NULL;<br />
}<br />
<br />
CDC memDC;<br />
memDC.CreateCompatibleDC(&screenDC);<br />
<br />
CBitmap bmpBitmap;<br />
bmpBitmap.CreateCompatibleBitmap(&memDC, 50,100);<br />
CBitmap *pOldBitmap = memDC.SelectObject(&bmpBitmap);<br />
<br />
CBrush blackBrush(RGB(0,0,0)),<br />
colorBrush(RGB(255,0,255));<br />
CBrush* pOldBrush = memDC.SelectObject(&blackBrush);<br />
<br />
memDC.Rectangle(0,0,50,100);<br />
<br />
memDC.SelectObject(&colorBrush);<br />
<br />
memDC.SetTextColor(RGB(255,0,255));<br />
memDC.SetBkMode(TRANSPARENT);<br />
<br />
memDC.DrawText("WTF", CRect(0,0,50,100), DT_SINGLELINE | DT_NOCLIP | DT_LEFT);<br />
<br />
memDC.SelectObject(pOldBitmap);<br />
memDC.SelectObject(pOldBrush);<br />
memDC.DeleteDC();<br />
<br />
<br />
img->CreateFromHBITMAP(bmpBitmap);<br />
<br />
return img;<br />
}<br />
The problem I'm having is that the text "WTF" doesn't show up in magenta like it says unless I add the line "generatedImg->SetPaletteColor(idx+1, RGB(255,0,255));". If I take that out, the GIF doesn't show up right.
The bigger problem with this is that I need to have my ISAPI Extension generate the GIF by assembling a bunch of BMP files together (bitmapped fonts) to generate an "image string", then encode it, save it, and provide a link back to the browser window. First, how would I create a CBitmap on an ISAPI Extension running on IIS for Windows 2003 so I can create the "image string". From there, how would I use CxImage to properly convert the image to GIF? Any ideas/suggestions?
|
|
|
|
|
What is in simple terms beteen between OnOk() and EndDialog and what is the command to close a program down as the commands above only close the dialog they belong to
Donald
|
|
|
|
|
OnOK is the method called when the OK button is pressed, it sets the dialog result to be ID_OK ( or something like that ). EndDialog just closes the dialog.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
OnOK calls UpdateData(true)
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
Calling CDialog::OnOK performs any data validation, then calls EndDialog with the result IDOK, so it essentially simulates a user clicking the OK button.
Depending on the situation, you may want to use OnCancel instead. It skips the data validation, and simply calls EndDialog with the result IDCANCEL.
(The IDOK/IDCANCEL values are what's returned from the DoModal function)
To close an app:
AfxGetMainWnd()->PostMessage(WM_CLOSE);
Pssst. You see that little light on your monitor? That's actually a spy camera, and I'm tracking your every move...
|
|
|
|
|
Hello,
I'm creating an app. that will run on various computers with various resolutions and styles. A window on my machine looks like the right size, but is too small on another's machine. I looked for an article on making my windows indpendent of the users' fonts, resolutions, etc, but to no avail.
Can anyone suggest a place to find this information?
thanks,
JennyP
|
|
|
|