|
#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
|
|
|
|
|
Hi,
i think that you have to include the resizing code
Have a look @ msdn related to CWnd::OnSize it does have an example
Hope that this might help you
Sujan
|
|
|
|
|
Hi,
how can I make an installation package for my application in vc++?
I've not found anything in the articles and messages, and i don't know how do it.
Thanks.
|
|
|
|
|
At the risk of starting a battle...
Check out InnoSetup at www.jrsoftware.org[^]
It's a great little program that is easy to use.
Make sure you also download the ISTool editor.
Brad
|
|
|
|
|
Thanks!!! It's very easy and i've got my package!
|
|
|
|
|
An hour from need to successful installer!
Glad I could help.
|
|
|
|
|
But if You ar eusing INNO Setup ,u should learn some pascal language as it is based on Pascal Scrpting
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I am trying to develop some extensions to the CSplitterWnd class and need to get the handle to the divider bar so I can add some features to this component of the class. Does anyone know how this can be done?
Specifically, I have some code that extends a divider to add a 'quick close' button and would like to incorperate this into our application's use of the SplitterWnd class. But I can't find the divider handle in the splitterWnd object to do this.
I'd appreciate any help.
Thanks.
-b
|
|
|
|
|
i m developer of network security and i have write program that make pc's in network more secure .
but i need some help for shutdown computer remotely useing
only one program instaled on server
please some source code or does'nt replay this message!
thank's
|
|
|
|
|
Take a look at InitiateSystemShutdown .
|
|
|
|
|
Look up ExitWindowsEx
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I want to have a screensaver that logs the current user off when the have been idle for X amount of time. I am currently using ExitWindows() function, but the user is not logging off. The return value is ok. I thought my screensaver might have to handle the message as well but OnQueryEndSession never gets called. The message catch, shown below, is in the same class as the ExitWindows call. This function was created through MFC wizard.
BOOL CDrawWnd::OnQueryEndSession()
{
return TRUE;
}
Any help or guidance will be very helpful.
|
|
|
|
|
jet9153 wrote:
I am currently using ExitWindows() function, but the user is not logging off.
Which means that some application is returning 0 in response to the WM_QUERYENDSESSION message. Do you agree?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Does it have to be within your screensaver? Windows has this functionality built in using Group Policies.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi
First: I am very new in programming dlls. I tried to make one to use it with A5 3DGameStudio (link[^]). I just made a new project (dynamic-link library Win32) - I use Visual C++ - a very simple dll including one function returning an int . Compiling done, tested with an Visual Basic DLL-Tester - it works. Now the 3DGS doesn't accept it . Error: "Dll not compatible with 3DGS" ...
Has anybody ever written a dll for a 3DGameStudio Game that works could you give me an exemple how this looks like, just the structur and which data types (int or long / double or float) I can return ?? I got no answers from the support , no informations on the side nor on fan sides .
thanks to all who read this
Greatings
Lukas
|
|
|
|
|
The function GetScrollBarInfo() doesn't return anything....does not matter what i do. if i use Getscrollinfo() it always returns a value but Getscrollbarinfo on the other hand doesn't...by the way anyone else noticed how complex microsoft implemented the scrollbar? I find it quite a pain to draw a skin on a scrollbar because of this issue
Oooh Joy...
|
|
|
|
|
|
Ok, so I have this formatting function because I need 2 digits after the exponent and VS7.1 puts out 3 by default. So anyway, the code is pretty verbose and slow. Anyone care to take the blinders off my eyes and optimize this?
std::string CDataFile::mf_FormatNumber(const int& iVariable, const int& iSample, const bool& bIsDAT_Format)
{
try
{
char buffer[200] = {0};
std::string numstring = "";
std::string buffstring = "";
std::string result = "";
if(bIsDAT_Format)
{
result = (m_v2dData.at(iVariable).at(iSample) >= 0.0) ? std::string(" ") : std::string("");
sprintf( buffer,"%.5E", m_v2dData.at(iVariable).at(iSample));
}
else
{
result = (m_v2dData.at(iVariable).at(iSample) >= 0.0) ? " " : " ";
sprintf( buffer,"%.17E", m_v2dData.at(iVariable).at(iSample));
}
numstring = buffer;
if(numstring.length()-numstring.find_last_of("E") == 5)
{
buffstring = numstring;
if(bIsDAT_Format)
numstring.resize((m_v2dData.at(iVariable).at(iSample) >= 0.0) ? 9 : 10);
else
numstring.resize((m_v2dData.at(iVariable).at(iSample) >= 0.0) ? 21 : 22);
numstring += buffstring[buffstring.find_last_of("E")+3];
numstring += buffstring[buffstring.find_last_of("E")+4];
}
result += numstring;
return result;
}
catch(...)
{
std::string szerr = "";
char errbuff[1024] = {0};
sprintf(errbuff,"ERROR formatting Var: %d Sample %d! \nDetails: %s", iVariable, iSample,m_szError.c_str());
szerr = errbuff;
return szerr;
}
}
~Nitron.
ññòòïðïðB A start
|
|
|
|