|
I find that my pointers are less likely to generate access violations if I use Courier.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
6 point Terminal
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
In my VS IDE, I use Lucinda Console - usually 10pt but if the resolution is higher I'll go up to 14pt
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
Finding a good font is the first milestone in the journey of becoming a master craftsman. I don't think I was even a programmer till I spent a day making my own programming font in Softy 3 years ago. I still use it and it's still awesome.
|
|
|
|
|
Fixedsys 9.
I want a clean proportional font - found it to be the best.
More important is the colour scheme:
Background - light grey
Normal test - black
Comment text - dark grey (comments blend with background - don't detract from reading code)
Selection margin - light grey
Keyword - dark blue
Number/string - dark red
Operator - dark green
Wizard code - black
User keyword - light blus
Highlight values - black on whatever
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I am using Visual Studio 6 to create my simple dialog-based program. In the setting, I have selected to "use MFC as a static library". After building, I get my Released version of my EXE program. This executiable file does run well on the PC on which I developed the program. However, for the PC without Visual Studio, I found the following problems
1. The EXE does not run at all on many Win XP or Win 2000 platforms where Visual Studio has never been installed before;
2. It seems that it is not because of the missing of certain DLLs. Usually when some DLLs are missing, there pops up a error message box saying which missing DLL is required, but in my case, just nothing happens when I double-click to invoke the program. I also downloaded dependancy analyzer software to see what system file is missing and try to add and register the missing system files manually, it is not useful at all.
If you have experienced the same problem and happens to know the solution, appreciate if you can share me with it.
|
|
|
|
|
Hello Dear
Can u tell me how to detact multiple VGA cards in Visual C++ or in Visual Basic.
Thanks a Lot
I will very thank ful to you for this consideration
Regards
Touqeer
Touqeer_khan@yahoo.com
|
|
|
|
|
but you are you shouting ????
|
|
|
|
|
but you are you shouting ????
|
|
|
|
|
Anonymous wrote:
but you are you shouting ????
Welcome Moderator!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Check out EnumDisplayDevices() .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hey, so I am having a lot of trouble with DirectDraw surfaces.
I set up my surfaces like this
LPDIRECTDRAWSURFACE7 lpdds;
LPDIRECTDRAWSURFACE7 lpddsBack;
DDSURFACEDESC2 ddsd;<br />
<br />
INIT_DDRAW_STRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;<br />
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP;<br />
ddsd.dwBackBufferCount = 1;<br />
<br />
if (FAILED(lpdd->CreateSurface(&ddsd, &lpdds, NULL)))<br />
return 105;<br />
<br />
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;<br />
<br />
if (FAILED(lpdds->GetAttachedSurface(&ddsd.ddsCaps, &lpddsBack)))<br />
return 106;
Now I attach a clipper to the back buffer. I then Blt() some pictures from a LPDIRECTDRAWSURFACE7 (created using the dwCaps value DDSCAPS_OFFSCREENPLAIN) to the back buffer. Next, I call:
if (FAILED(lpdds->Flip(NULL, DDFLIP_WAIT)))<br />
return 201;
When I do that, the images I Blitted are displayed, and everything is fine. I then Blt() some more images onto the back buffer for the next frame of animation. When I call the flip command, my screen turns black. It's as if I cannot Blt() anything to the memory originally associated with lpdds (primary surface).
The really odd thing though, is that I have error checking on all my DirectDraw calls(With FAILED()) and nothing is returning an error.
Also, a few other pieces of misc data that might be useful, the LPDIRECTDRAWSURFACE7's are actually members of a class called GraphicsEngine. This class is in a .h file I am writing, but I am making the Flip() and Blt() calls from the main .cpp file. (I made everything public until I fix this problem)
If anyone can help me with fixing this, I'd really appricate it.
|
|
|
|
|
what does the membership function make?
help me.
thanks.
|
|
|
|
|
Hi all! I'm a newbie to this site, and very new to Vis. C++. I am trying to write a program wich will display an incomming Binary Waveforms from a data file (yet to be determined). The Data file is eight bits wide. I'm not quite sure how to begin this. I plan on using GDI+ to handle the graphic operations. Looking at some other GDI+ functions, using the DrawString function seemed too teidous, to me, for waveforms that may be up to 1.5 MBits long. When the program is completed there will be a display of eight of these Graphs each from a column in the data file. Any suggestions, or code would be grately appreciated.
|
|
|
|
|
Please be aware that I am a hack a total newbie to C++. I'm using Visual C++ 6.0
I have written a program to process a rectangular 2D data set and then output the 2D result
as a graphic. I have created a bitmap type structure with the resulting data. I can
currently write the created bitmap out to a BMP file, then re-load the same file and
finally display the graphic. I want to be able to just display the graphic, instead of
first going to/from disk. I've got something that displays a black rectangle instead of
the graphic. For several weeks I've been searching for a good example and have yet to find
something that works for me. I think that I'm just a line or two of code away from getting
this to work, I was hoping someone out here could help. Here's what I have:
------------- The following code works fine ----------------
// MaxArrayDim = a const value defined earlier
BYTE aBitmapBits[MaxArrayDim * MaxArrayDim * 3];
//... a bunch of code is omitted where:
// - Raw 2D data is processed and mapped to RGB data and stored in aBitmapBits
// - Physical values (NumOfBytes, NumCols, NumRows) are determined
//
BITMAPFILEHEADER BitmapFileHeader;
BITMAPINFOHEADER BitmapInfoHeader;
RGBQUAD aColors[4];
BitmapFileHeader.bfType = 0x4d42; // = 'BM'
BitmapFileHeader.bfSize = NumOfBytes + 54;
BitmapFileHeader.bfReserved1 = 0;
BitmapFileHeader.bfReserved2 = 0;
BitmapFileHeader.bfOffBits = 54;
BitmapInfoHeader.biSize = 40;
BitmapInfoHeader.biWidth = NumCols;
BitmapInfoHeader.biHeight = NumRows;
BitmapInfoHeader.biPlanes = 1;
BitmapInfoHeader.biBitCount = 24;
BitmapInfoHeader.biCompression = 0;
BitmapInfoHeader.biSizeImage = NumCols * NumRows * 3;
BitmapInfoHeader.biXPelsPerMeter = 3780;
BitmapInfoHeader.biYPelsPerMeter = 3780;
BitmapInfoHeader.biClrUsed = 0;
BitmapInfoHeader.biClrImportant = 0;
// Not needed. No color map necessary for 24-bit.
aColors->rgbBlue = 0;
aColors->rgbGreen = 0;
aColors->rgbRed = 0;
aColors->rgbReserved = 0;
//Output as a BMP file
char FileName[] = "junk.bmp";
FILE *output_file; // output file pointer
// Open the data file for output
if ((output_file = fopen(FileName, "wb")) != NULL)
{
// Output the File Header, Info Header and data bytes.
fwrite(&BitmapFileHeader.bfType, sizeof(short int), 1, output_file);
fwrite(&BitmapFileHeader.bfSize, sizeof(long int), 1, output_file);
fwrite(&BitmapFileHeader.bfReserved1, sizeof(short int), 1, output_file);
fwrite(&BitmapFileHeader.bfReserved2, sizeof(short int), 1, output_file);
fwrite(&BitmapFileHeader.bfOffBits, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biSize, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biWidth, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biHeight, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biPlanes, sizeof(short int), 1, output_file);
fwrite(&BitmapInfoHeader.biBitCount, sizeof(short int), 1, output_file);
fwrite(&BitmapInfoHeader.biCompression, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biSizeImage, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biXPelsPerMeter, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biYPelsPerMeter, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biClrUsed, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biClrImportant, sizeof(long int), 1, output_file);
// write out the data bits
fwrite(&aBitmapBits[0], sizeof(char), NumOfBytes, output_file);
fclose(output_file);
}
bool ReadGraphicFromFile = true; // set manually to test different methods
if (ReadGraphicFromFile)
{
// The code below works fine, but it displays the bitmap by reading
// it from the Junk.bmp file that was written.
CString szFilename("junk.bmp");
hBmp = (HBITMAP)::LoadImage(NULL,szFilename,IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
}
else
{
// ***** Here's where the problem lies *****
// hBmp = (something else based on bitmap data from memory)
}
CBitmap bmp;
bmp.Attach(hBmp);
CDC bmDC;
bmDC.CreateCompatibleDC(&dialogDC);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dialogDC.StretchBlt(xLeft,yTop,xMaxWidth,yMaxHeight,&bmDC,0,0,
bi.bmWidth,bi.bmHeight,SRCCOPY);
bmDC.SelectObject(pOldbmp);
------------- End of code example ----------------
The creation of the bimap structure and writing out the file, I understand just fine.
All of the stuff after it, starting with LoadImage, I got from:
http://www.codeguru.com/Cpp/G-M/bitmap/displayingandsizing/article.php/c4905/
(Thanks to Ramakrishna Talla for that post)
Although there may be other ways to accomplish the same end, I figured if I could
create a bitmap in memory in the same form as the LoadImage gives me, with the "hBmp"
handle, then I would be all set.
I think that the answer may lie in CreateDIBSection, but the (void**)ppvbits thing
has got my brain all confused and I can't figure out how to get my data over to the
right place. I'm just flailing away with different things and all I'm getting is
a big black rectangle where I want to get a color graphic. I'd include some of that
code, but all I have is various snippets of code I've found on-line and it's a mess.
Can someone recommend some code to accomplish what I'm trying to do, or perhaps
point me to a reference for this?????
I've found tons of examples for using a bitmap resource, but only a couple that
explain loading from a file, and none (yet) that explain how to do what I'm trying
to do. I've found many that use CreateDIBSection and code similar I have above for
doing the outputing, but the step where the real data bits get copied or some
pointer gets re-specified seem to be omitted. Maybe this is assumed trivial and
because of my newbie ignorance I just can't make the leap to get there. This seems
like something that would be done a lot. Just last night I started looking into gaming
type books in the hopes that I can find something, but I haven't found it yet. (
Any help on this would be greatly appreciated.
|
|
|
|
|
DIBSections are pretty easy. You specify what you want (using a BITMAPINFO structure, like you already are), and Windows gives you memory that you can write to. You just pass in a pointer to the pointer you want to use to reference this:
unsigned char* pBmpData = NULL;
HBITMAP hBmp = CreateDIBSection(hDC, pbmInfo, DIB_RGB_COLORS, (void**)&pBmpData, NULL, 0);
Then you just need to copy your bitmap data into the memory Windows allocated for you:
memcpy(pBmpData, &aBitmapBits[0], NumOfBytes);
And you're ready to do something fun with your new bitmap. Don't forget to delete the bitmap when you're done with it though (using DeleteObject() )... and that'll free the memory used as well, so don't be using that pointer afterwards. Enjoy!
Medication for us all
You think you know me, well you're wrong
|
|
|
|
|
shog9,
Fantastic! Thanks much.
I had been trying code dangerously close to this, and as I feared I was just a misdeclaration and a couple punctuation marks away from stumbling on the answer. I've been circling this problem for about 2 weeks! Shows what ignorance will get you.
So, what's you poison, and where do I send it?
Mike
|
|
|
|
|
Thanks to shog9's response, I have the answer to my question. I have combined his solution
into my original code example so others my not have to dig quite a long and deep as I have
been.
Please be aware that I am a hack a total newbie to C++. I'm using Visual C++ 6.0.
Any mistakes are mine.
I have written a program to process a rectangular 2D data set and then output the 2D result
as a graphic. I have created a bitmap type structure with the resulting data. I was able
to figure out how to write the created bitmap out to a BMP file, then re-load the same file
and finally display the graphic. I wanted to be able to just display the graphic directly,
instead of first going to/from disk. With the info I got from shog9, I was able to
accomplish this goal. So, I am creating a bitmap graphic on-the-fly and then displaying it.
-------------------- Example Code ----------------
// MaxArrayDim = a const value defined earlier
BYTE aBitmapBits[MaxArrayDim * MaxArrayDim * 3];
//... A bunch of code is omitted where:
// - Raw 2D data is processed and mapped to RGB data and stored in aBitmapBits
// - Physical values are determined:
// NumOfBytes, NumCols, NumRows of the bitmap
// xLeft, yTop = coordinates to draw bitmap at
// xMaxWidth, yMaxHeight = size of display area
//
BITMAPFILEHEADER BitmapFileHeader;
BITMAPINFOHEADER BitmapInfoHeader;
RGBQUAD aColors[4];
BitmapFileHeader.bfType = 0x4d42; // = 'BM'
BitmapFileHeader.bfSize = NumOfBytes + 54;
BitmapFileHeader.bfReserved1 = 0;
BitmapFileHeader.bfReserved2 = 0;
BitmapFileHeader.bfOffBits = 54;
BitmapInfoHeader.biSize = 40;
BitmapInfoHeader.biWidth = NumCols;
BitmapInfoHeader.biHeight = NumRows;
BitmapInfoHeader.biPlanes = 1;
BitmapInfoHeader.biBitCount = 24;
BitmapInfoHeader.biCompression = 0;
BitmapInfoHeader.biSizeImage = NumCols * NumRows * 3;
BitmapInfoHeader.biXPelsPerMeter = 3780;
BitmapInfoHeader.biYPelsPerMeter = 3780;
BitmapInfoHeader.biClrUsed = 0;
BitmapInfoHeader.biClrImportant = 0;
// Not needed. No color map necessary for 24-bit.
aColors->rgbBlue = 0;
aColors->rgbGreen = 0;
aColors->rgbRed = 0;
aColors->rgbReserved = 0;
//Output as a BMP file
char FileName[] = "junk.bmp";
FILE *output_file; // output file pointer
// Open the data file for output and write file "junk.bmp"
if ((output_file = fopen(FileName, "wb")) != NULL)
{
// Output the File Header, Info Header and data bytes.
fwrite(&BitmapFileHeader.bfType, sizeof(short int), 1, output_file);
fwrite(&BitmapFileHeader.bfSize, sizeof(long int), 1, output_file);
fwrite(&BitmapFileHeader.bfReserved1, sizeof(short int), 1, output_file);
fwrite(&BitmapFileHeader.bfReserved2, sizeof(short int), 1, output_file);
fwrite(&BitmapFileHeader.bfOffBits, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biSize, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biWidth, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biHeight, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biPlanes, sizeof(short int), 1, output_file);
fwrite(&BitmapInfoHeader.biBitCount, sizeof(short int), 1, output_file);
fwrite(&BitmapInfoHeader.biCompression, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biSizeImage, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biXPelsPerMeter, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biYPelsPerMeter, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biClrUsed, sizeof(long int), 1, output_file);
fwrite(&BitmapInfoHeader.biClrImportant, sizeof(long int), 1, output_file);
// write out the data bits
fwrite(&aBitmapBits[0], sizeof(char), NumOfBytes, output_file);
fclose(output_file);
}
HBITMAP hBmp; // This is the target bitmap
HDC dcMap = CreateCompatibleDC(NULL);
ASSERT(dcMap);
// Set ReadGraphicFromFile manually & recompile to test different methods
// true = use LoadImage to get bitmap from file
// false = use CreateDIBSection and move data from memory
bool ReadGraphicFromFile = false; // set manually to test different methods
if (ReadGraphicFromFile)
{
// Load the bitmap data from file "junk.bmp", which was saved above.
CString szFilename("junk.bmp");
hBmp = (HBITMAP)::LoadImage(NULL,szFilename,IMAGE_BITMAP,0,0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
}
else
{
// Here's the code I got from shog9 (modified to work here), including
// his explanations:
// DIBSections are pretty easy. You specify what you want (using a BITMAPINFO
// structure, like you already are), and Windows gives you memory that you can
// write to. You just pass in a pointer to the pointer you want to use to
// reference this:
unsigned char* phBmpBits = NULL;
hBmp= CreateDIBSection( dcMap,&infoMap,DIB_RGB_COLORS,
(void**)&phBmpBits,NULL,0 );
// Then you just need to copy your bitmap data into the memory Windows allocated
// for you:
memcpy(phBmpBits, &aBitmapBits, (NumCols * NumRows * 3));
// And you're ready to do something fun with your new bitmap. Don't forget to
// delete the bitmap when you're done with it though (using DeleteObject())...
// and that'll free the memory used as well, so don't be using that pointer
// afterwards. Enjoy!
}
CBitmap bmp;
bmp.Attach(hBmp);
CDC bmDC;
bmDC.CreateCompatibleDC(&dialogDC);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dialogDC.StretchBlt(xLeft,yTop,xMaxWidth,yMaxHeight,&bmDC,0,0,
bi.bmWidth,bi.bmHeight,SRCCOPY);
bmDC.SelectObject(pOldbmp);
DeleteObject(hBmp);
------------- End of Example Code ----------------
I'm probably missing some more memory housekeeping here, so be careful!
|
|
|
|
|
Is it possible to create a thread from a non-member function? Is there another way to do this?
Here is my code:
#using <mscorlib.dll>
using namespace System::Threading
__declspec(dllimport) BOOL InstallHook();
void main()
{
ThreadStart* workDelegate = new ThreadStart(0, InstallHook);
// the rest..
}
I get error C3363 cannot create delegate handler for a non-member function or unmanaged class
Thanks
|
|
|
|
|
//simple code
STARTUPINFO si={0};
si.cb=sizeof(si);
si.dwFlags=STARTF_USESTDHANDLES;
CreateProcess(....,&si,....);
After parent process uses code above to create a child process, can parent read and write to si.hStdOutput, si.hStdError and si.hStdInput to child process directly without using function CreatePipe() to establish pipes to handles of si?
I remember that CraetePipe() must be used for communication between parent and child, but not sure, please comfirm if I am correct or wrong.
thx
includeh10
|
|
|
|
|
Hi,
I am trying to parse my XML file using the XML parser pXMLPArser to accomplish the following tasks-
pXMLParser->ReplaceNodeVale("input\userinputkey", szUserInput);
pADOObject->GetNextPrompt(pXMLParser->Getxml(), szxml();
pXMLParser->Release();
pXMLParser->Loadxml(szxml);
pXMLParser->GetNodeValue("output\messageid", szNodeVale);
Here's my XML file that I am trying to parse-
<?xml version="1.0" encoding="utf-8" ?>
- <root>
- <input>
<nodeid>0</nodeid>
<parentid>0</parentid>
<userinputkey>9167791963</userinputkey>
</input>
- <output>
- <vrurequestscript>
- <datainput>
<mainmsgid>100</mainmsgid>
<correctvalues>1,2</correctvalues>
<charset>12</charset>
<length>1</length>
<timeout>10000</timeout>
<timeoutmsgid>200</timeoutmsgid>
<retrycount>3</retrycount>
<retryexitaction>end</retryexitaction>
<retryexitmsgid>300</retryexitmsgid>
</datainput>
- <confirminput>
<mainmsgid>101</mainmsgid>
<correctvalues>1,2</correctvalues>
<charset>12</charset>
<accept>1</accept>
<reject>2</reject>
<length>1</length>
<timeout>10000</timeout>
<timeoutmsgid>200</timeoutmsgid>
<retrycount>3</retrycount>
<retryexitaction>end</retryexitaction>
<retryexitmsgid>300</retryexitmsgid>
</confirminput>
</vrurequestscript>
<nodeid>0</nodeid>
<parentid>0</parentid>
</output>
</root>
Can someone please show me how to go about doing it. This is my first time dealing with XML parser's so it's confusing getting an idea about people's classes that deal with parsers.
Thanks a bunch.
-Ray
|
|
|
|
|
Hi All,
Given a 24-bit image in a bitmap file, how do I draw it such that it appears to be "disabled" with transparent background?
I tried various ways such as combining DrawState with DSS_MONO, DSS_DISABLED but they did not give me a desired outcome.
Thanks in advance!
|
|
|
|
|
use BitBlt fuction with SRCAND or SRCPAINT
|
|
|
|
|
Not sure if the answer is simple or not, but I'm trying to track down a bunch of memory leaks in some code from an article here and in tracing through the code, my WTF-meter is starting to glow a bit. Does it make sense to define a member function as static, then within that method, call another static member function and then within the second static member function, create an instance of your self on the stack in order to call non-static functions and then invoke pseudo copy constructors to copy member data from the stack based object to parameters that were passed to the static member function call. If you can understand that description, my question really comes from, why would the functions be made static in the first place. Had they not been made static, there would be no need to instantiate a stack object, nor copy it's member data into parameters in the first place. It seems like jumping through hoops for the sake of hoop jumping. Any comments or thoughts? Thanks.
Chris Meech
I am Canadian. [heard in a local bar]
Remember that in Texas, Gun Control is hitting what you aim at. [Richard Stringer]
Nice sig! [Tim Deveaux on Matt Newman's sig with a quote from me]
|
|
|
|
|