|
Hi
I need to know if anyone have good VC++ Source for a Cataloguer like "Advanced Disk Catalog" or any good reference site ?
TIA
BLaZe
|
|
|
|
|
to compare 2 strings one uses strcmp, but what about integers? is there a strcmp alternative for int/float?
check out the code see what i mean
void binSort(FILE * pt, int struSize, int n)
{
float i, j, minPos;
struct Planet iRec, jRec, temp;
for(i = 0; i < (n-1); i++)
{
fseek(pt, 0L, SEEK_SET);
fseek(pt, (i*struSize), SEEK_CUR);
fread(&iRec, struSize, 1, pt);
for(j = (i+1); j < n; j++)
{
fseek(pt, 0L, SEEK_SET);
fseek(pt, (j*struSize), SEEK_CUR);
fread(&jRec, struSize, 1, pt);
if(strcmp(jRec.diameter, iRec.diameter) < 0)
{
temp = iRec;
iRec = jRec;
jRec = temp;
fseek(pt, 0L, SEEK_SET);
fseek(pt, (i*struSize), SEEK_CUR);
/*swap records*/
/*fwrite(&iRec, struSize, 1, pt);*/
printf("iRec = %fn", iRec);
fwrite(&iRec, struSize, 1, pt);
fseek(pt, 0L, SEEK_SET);
fseek(pt, (j*struSize), SEEK_CUR);
fwrite(&jRec, struSize, 1, pt);
}
} /*end j*/
} /*end i*/
}
its all good until 'if(strcmp(jRec.diameter, iRec.diameter) < 0)'. since jRec/iRec.diameter are declared as floats i get mismatch errors. im working with structures, files, etc, so i wanna know if there are any strcmp alternative or do i have to code a seperate function?
|
|
|
|
|
If the "diameter" member is just a float, use the normal < operator:
if ( jRec.diameter < iRec.diameter )
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
1.
What is the best progress for loading images and displaying them on a DC? Is there a single function covering this?
I know from DirectX that there is a standardfunction for loading .BMP's there, but the GDI/DC-world is new to me..
2.
I try to do DestroyWindow() to quit my DialogueBox, however, I only get "Debug Assertion Failure".. what's the correct way to shut down your own window?
On forehand thanx,
Thomas
|
|
|
|
|
(addressing question 2) Where is the assert? What test is failing?
If your dialog is modal, you use EndDialog(). DestroyWindow() is used only for modeless dialogs.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|
|
Yes, EndDialog(int) did the trick, thanks a lot!
You wouldn't know how to load and display images from Win GDI as well?
Thomas
|
|
|
|
|
GDI+ knows how to load images from disk, in GDI you can use ::LoadImage to load a .bmp, but no other format is supported. You can try a library like paintlib if you want to load jpg, etc. You need to load the image in and select it into a DC. Then you can manipulate it or copy to a ClientDC/PaintDC if you want to see it.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
|
|
|
|
|
Yes, LoadImage is present for DirectX too, and only .bmp-files also for that.. great, I couldn't find it anywhere in my MSDN lib because I thought it had a different name.
I will try out the paintlib; it'd be nice to be able to load jpg's too..
Thanks again (to both of you)!
Thomas
|
|
|
|
|
I wondering what code is that ti be added to a dialog based app if I want serialazing?
BETA
|
|
|
|
|
I wondering what code is that ti be added to a dialog based app if I want serialazing?
BETA
|
|
|
|
|
I'm working on a project that has to extract data from an INI file using GetPrivateProfileString. Under Windows 2000, my code works fine, but under Win9x and WinME, it fails.
The INI file in question is formatted like so:
[ SectionName ]
KeyName = SomeValue\t\t; comment
Notice that there are spaces in the "[ SectionName ]", as well as before and after the "=" sign in the key value assigments.
I'm using this code to read the file:
GetPrivateProfileString(" Section Name ", "KeyName", "", 255, "C:\Path\MyFile.ini");
I've tried all combinations of leading and trailing spaces for the section and key names in the GetPrivateProfileString call, but it still refuses to work in Win9x. I can't change the file tro be "compatible" because I'm not the one that generated the file, and besides, it might screw up the original program if I did so.
Anybody got any hints or suggestions?
|
|
|
|
|
I *was* going to point out that .ini files are six years obsolete, but apparently you're stuck with them. I'm surprised at the order of your problem, I'd have thought if anything the legacy code would be broken later ( i.e. Win2K ) rather than a problem where only Win2K works. Is there any reason why you can't just open the file and parse it yourself ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
|
|
|
|
|
Well, I'm not really a believer of Microslop's mantra that all program settings belong in the registry, so I only use it when it's required. But beyond that little personal item....
I'm gonna try just removing the offending white spaces from the file, and writing it back to the disk. Then, it *should* work fine on any version of Windows. How it affects the original program that uses this file has not yet been determined.
This is admittedly the most bizarre thing I've seen in a while (if you don't count .NET).
|
|
|
|
|
I scrubbed the files and a) the original program that uses them still works, and b) now mine does too.
The requirement to do so is freaky though.
|
|
|
|
|
Hi !
How can I get a controls HWND ?
|
|
|
|
|
For example the ID of the dialog control is IDC_BUTTON2.
CWnd *pWnd = GetDlgItem(IDC_BUTTON2);
if (pWnd)
{
HWND hwnd = pWnd->m_hWnd;
// hwnd is your handle to the control
}
I hope I could help you...
Gregor Mitsch
E-Mail: abacus-@gmx.de
|
|
|
|
|
Hi Gregor Mitsch!
do you know how to use this function bellow? I found it in the sdk, but fail to use it. Basically, I have 2 dialog. I need to change a value of an edit box on the second dialog, when a button on the first dialog is clicked.
//here is the function prototype
HWND GetDlgItem(
HWND hDlg, // handle to dialog box
int nIDDlgItem // control identifier
);
Thank You
Vu
vucsuf
|
|
|
|
|
You need to say ...
HWND hwnd = ((CastMainWindow*)AfxGetMainWnd)->NameOfControl;
|
|
|
|
|
|
|
i wonna prepare the image (in bmp)
void CTestView::Test()
{
CClientDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
memDC.Ellipse(0,0,200,200);//prepare image
CBitmap bmp;
HBITMAP hBmp=::CreateCompatibleBitmap(dc.GetSafe, 200, 200); // <---------?
bmp.Attach(hBmp);
memDC.SelectObject(&bmp);
//mus be ellipse in dc but...
dc.BitBlt(0, 0, 200, 200, memDC, 0, 0, SRCCOPY);
}
quastion is:
how prepare the image in bitmap and bitblt.. it to main dc?
and what doing the function ::CreateCompatibleBitmap() (in this sample code) ?..
big thx.
|
|
|
|
|
CreateCompatibleBitmap creates a bitmap compatible with a device context. You can just create a bitmap and use GetDeviceCaps(dc.m_hDC, BITSPIXEL) if you prefer - the net result is the same.
By selecting a bitmap into a DC you get sent back the old one that was in the DC, this is one reason why the call to Ellipse does nothing. The second is that until you select a HBITMAP, CBitmap or DIBSection into a DC, it has a size of 1 x 1 x 1, one bit in total. This is clearly of no value
Select the bitmap into the DC first, then draw to your hearts content, the memory bitmap will then be created and able to be blted across. One more caveat - if you use functions like Ellipse as opposed to FillSolidRect ( which takes a pointer to a brush ), then the drawing will be done in the default brush colour, and I'm not sure if Windows offers any guarentees as to what that would be ( but I'd guess white pen, white brush, black bitmap ). Either way, you'd do better to be sure and create your own, and catch all the returns to avoid memory leaks.
Oh - I nearly forgot - call CClientDC at the LAST possible minute to avoid flicker, which I presume is the whole point ?
So here is the final code:
CDC memDC;
memDC.CreateCompatibleDC(NULL);
CBitmap bitmap;
bitmap.CreateBitmap(200, 200, 1, GetDeviceCaps(memDC.m_hDC, BITSPIXEL), NULL);
CBitmap * pOldBitmap = (CBitmap*)memDC.SelectObject(&bitmap);
CBrush red (RGB( 255, 0, 0));
memDC.FillSolidRect(0, 0, 200, 200, &red); // Or create pens/brushes and select the same as we did the bitmap, catching the return of the same type, then you can draw whatever you like...
CClientDC dc(this);
dc.BitBlt(0, 0, 200, 200, &memDC, 0, 0, SRCCOPY);
memDC.SelectObject(pOldBitmap); // And any other objects we selected in, otherwise we get memory leaks
memDC.DeleteDC();
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
|
|
|
|
|
how can write(not from keyboard) in window from CEditView the next text:
"first string
second string
"
using methods of this class. (?)
thx.
|
|
|
|
|
The easiest way is to use SetWindowText method from CEditView object.
|
|
|
|
|
We've got a problem:
We want to load data from a CFile object:
CFile m_ArrFile;
m_ArrFile.Open(m_strArrFile, CFile::modeRead);
char tmp[10];
[...]
UINT bytes = 0;
for (UINT x = 0; x < elemX; x++)
{
bytes += m_ArrFile.Read(&tmp, sizeof(int));
}
No matter how large the file is, the variable "byte" contains only 712 bytes after the loop. Why is it like that and what can we do against it? We use Windows ME.
Gregor & Dominik
|
|
|
|
|