|
Hi.
Add to your table field OLE object named "image".
In your program write:
CFile file;
CByteArray array;
BYTE z;
file.Open(.....);
for(int i=0;i<(unsigned int)file.GetLength();i++)
{
file.Read(&z,1);
array.Add(z);
}
COleVariant ole(array);
AddNew();
SetFieldValue("image",ole);
Update();
Probably better idea is to use operator >> to read from CArchive object but I don't know how. Error message ocurs.
|
|
|
|
|
Hi,
I've made small shellextension and it works fine. Next, I want to add propertysheet extension. So I read one Complete Idiot's guide. Because I love WTL, I've tried to use CPropertyPage from WTL in AddPages method of IShellPropSheetExt interface. But when the extension is called, it goes down with "the memory cannot be read" in altwin.h. I cant find a way through. Can anyone help?
HRESULT CDbfExtension::AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
{
HPROPSHEETPAGE hPage;
CPropertyProppage m_PropPage;
m_PropPage.m_psp.dwFlags|=PSP_PREMATURE;
m_PropPage.SetTitle(_T("DBF INFO"));
hPage=m_PropPage.Create();
if ( NULL != hPage )
{
// Call the shell's callback function, so it adds the page to
// the property sheet.
if ( !lpfnAddPage ( hPage, lParam ))
DestroyPropertySheetPage ( hPage );
}
return S_OK;
}
|
|
|
|
|
Your CPropertyProppage object is going out of scope, so the corresponding window (the page) gets destroyed. You need to move the object out of the AddPages() function.
--Mike--
http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
It's true. But when I change the CPropertyPage to a class-member, it happens again. I've found, that my shell/extension is destroyed ( shell calls Release() ) imidietly after AddPages() returns.
Later:
I've found a way but...
m_PropPage.m_psp.dwFlags|=PSP_USEREFPARENT|PSP_PREMATURE;
m_PropPage.m_psp.pcRefParent=reinterpret_cast<uint far*="">(&_Module.m_nLockCnt);
...
The PSP_USEREFPARENT is important, but this also doesn't work.
|
|
|
|
|
Ok, I ran into the same problems when I first did the Idiot's Guide article on property sheet extensions.
If there's anything that needs to persist beyond the lifetime of the extension object (which, as you've seen, gets destroyed before the property sheet appears) then you need to allocate it on the heap. Read over http://home.inreach.com/mdunn/
"That probably would've sounded more commanding if I wasn't wearing my yummy sushi pajamas."
-- Buffy
|
|
|
|
|
Thanks, it wokrs now. I use global variable for the CPropertyPage. There need to be free g_... in DllMain too.
|
|
|
|
|
I program for a hobby and only have Visual C++ 5 with service pack 3 and no there is no way I can afford VC++ 6. Now I keep seeing projects for VC++ 6. I try to build them in 5 and I cannot. Is there any way to update my libs and includes so that I can compile these projects for Visual C++ 6. Or am I out of luck. Hopefully I am not out of luck!
|
|
|
|
|
Hi !!
Just create new project "Win32 Application" with opntion = "An empty project"
after it copy all files from example project to your new ProjectFolder
without *.dsw,*dsp(its just project files info)
Next step :
In "WorkSpace"-window select tab "FileView"
in folder "Source Files" click MouseRightButton and select "Add Files to Folder.." from Menu
and select all needed files ( *.h, *.cpp, *.rc)
Select from VisualStudio menu "Project">"Settings" and in "all configurations"
in the first tab select "Use MFC in....." from ComboBox , press "OK"
Dont forgot coping "RES" folder to your new project.
After it press F7
hopefully i'm did't any mistakes in this Doc )
Sorry my English so....
Good Luck !!
|
|
|
|
|
I'm a flesh VC programer, and now I must add a shortcut
of a program to the desktop using VC++, but I don't know
how to make it.
I need help, please help me.
Thank you very much indeed.
|
|
|
|
|
Check out the IShellLink interface in MSDN.
HTH, Jens
|
|
|
|
|
Hi im working on a project that requires me to use a status bar of type CStatBarCtrl, and in that object it must have 4 panes... 3 of these four panes mush have text in them that is colored differently than the other 2 as kinda a key to let users know what colors mean what..My problem is I have everything working just fine, except the coloring of the text.. This is supposed to turn out very similar to the Visual Source safe show differences dialog text at the bottom of the status bar... If anyone knows anything , help would be greatly appreciated.
Please email me
sincerely
Josh B. Williams
|
|
|
|
|
Not such a stupid question. Probably the fastest for now is to have a look at Julian Smart's page..
http://www.anthemion.co.uk/
and his CEnhStatusBar Class as guide.
Alternatively overide the OnPaint for your status bar and then you will have paint every paint yourself. Or place Static controls on the Status bar and change the text colour in those.
Happy programming!!
|
|
|
|
|
hi I need to archive a screen capture output to a file . Can anyone help me ? The screencapture source code is shown below or does anyone has a better suggestion about doing it by altering the code below?
// Create a copy of the current system palette.
HPALETTE GetSystemPalette()
{
HDC hDC;
HPALETTE hPal;
HANDLE hLogPal;
LPLOGPALETTE lpLogPal;
// Get a DC for the desktop.
hDC = GetDC(NULL);
// Check to see if you are a running in a palette-based video mode.
if (!(GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)) {
ReleaseDC(NULL, hDC);
return NULL;
}
// Allocate memory for the palette.
lpLogPal = GlobalAlloc(GPTR, sizeof(LOGPALETTE) + 256 *
sizeof(PALETTEENTRY));
if (!hLogPal)
return NULL;
// Initialize.
lpLogPal->palVersion = 0x300;
lpLogPal->palNumEntries = 256;
// Copy the current system palette into the logical palette.
GetSystemPaletteEntries(hDC, 0, 256,
(LPPALETTEENTRY)(lpLogPal->palPalEntry));
// Create the palette.
hPal = CreatePalette(lpLogPal);
// Clean up.
GlobalFree(lpLogPal);
ReleaseDC(NULL, hDC);
return hPal;
}
// Create a 24-bit-per-pixel surface.
HBITMAP Create24BPPDIBSection(HDC hDC, int iWidth, int iHeight)
{
BITMAPINFO bmi;
HBITMAP hbm;
LPBYTE pBits;
// Initialize to 0s.
ZeroMemory(&bmi, sizeof(bmi));
// Initialize the header.
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = iWidth;
bmi.bmiHeader.biHeight = iHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
// Create the surface.
hbm = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pBits, NULL, 0);
return(hbm);
}
|
|
|
|
|
If you want to save the image in bitmap form there are some articles on this site or codeguru.com that show you how to do that. You may also like to investigate the ImgSource DLL which can save other image formats and has some bonuses in providing other image processing functions as well.
Happy programming!!
|
|
|
|
|
If you create a DC using CreateWindowDC(NULL) it will point to the whole screen. As well as using this to Blt TO the screen, you can Blt FROM it into a DC, and thus create the bitmap you want to save out. I recommend using Paintlib to sav your bitmaps, not least because of the ability to save jpg's and do funky stuff on the way. www.paintlib.de.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hi , I need to know how to complie a .h file as I cannot do it because the complier says i dun have a complier tool. Thanks for helping
|
|
|
|
|
This is normal. If you have a .h file open in the VC IDE and hit ctrl-F7, you get this message.
VC associaltes C and CPP files with translation units, not .h files. I don't know of a good answer why, or if an association can be set for .h files. Never tried.
To compile the header, just make a .cpp file that includes it, and compile that.
|
|
|
|
|
Can anyone recommend a good visual c++ book for beginners ?
|
|
|
|
|
How much of a beginner ? Visual C++ in24 hours is nice & clear, long term MFC Programming using isual C++ Unleashed goes into more epth and is a long term reference.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
I'm new to both Windows and Visual C++. About a year ago I did some slight programming in it and really enjoyed myself. I was wondering what I should read/do to get a good start. I know the ANSI/Console C++ rather well, I'm just new to the pure OO programming aspect of MFC/Windows SDK. Also, you can use both MFC and the Win SDK with the VC++ compiler, or not? Thank you for taking the time to read/answer this.
-Scott
|
|
|
|
|
In answer to question 2: yes, you can elect to use MFC or exclude it from your project when you set up with the new project wizard. Check my answer to the above question re: books.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
Hello all,
Before I ask the question/state the problem here is some
sample code.
int someFunction(int param1,
int param2)
{
int localVar1;
int localVar2;
localVar1 = callAFunc1();
localVar2 = callAFunc2();
return localVar1 + localVar2;
}
The question is, if I was writing a debugger and I had the address of say, localVar1 or localVar2 and I knew it was on the stack. Does anyone know how to translate the stack address into a variable name?
I know how to get the function name etc, but how do I get
the variable name?
Stephen Kellett
(still not logged on, obviously I can't even remember my new password...sigh)
|
|
|
|
|
I need a clever tip, about getting the right mouse button over a Picture Box.
|
|
|
|
|
You mean capturing OnContextMenu over an image ? YOu need to catch it in the control showing the picture, or if showing a picture is all you are doing, draw it yourself and check if your mouse is over it when you catch OnContextMenu in the parent window.
Christian
The content of this post is not necessarily the opinion of my yadda yadda yadda.
To understand recursion, we must first understand recursion.
|
|
|
|
|
hi can anyone explain to me how the sample code below (which shows a screen capture) works? I mean can anyone read the code below and explain in detail how this code works . Thanks a million for helping.
sample code
// Create a copy of the current system palette.
HPALETTE GetSystemPalette()
{
HDC hDC;
HPALETTE hPal;
HANDLE hLogPal;
LPLOGPALETTE lpLogPal;
// Get a DC for the desktop.
hDC = GetDC(NULL);
// Check to see if you are a running in a palette-based video mode.
if (!(GetDeviceCaps(hDC, RASTERCAPS) & RC_PALETTE)) {
ReleaseDC(NULL, hDC);
return NULL;
}
// Allocate memory for the palette.
lpLogPal = GlobalAlloc(GPTR, sizeof(LOGPALETTE) + 256 *
sizeof(PALETTEENTRY));
if (!hLogPal)
return NULL;
// Initialize.
lpLogPal->palVersion = 0x300;
lpLogPal->palNumEntries = 256;
// Copy the current system palette into the logical palette.
GetSystemPaletteEntries(hDC, 0, 256,
(LPPALETTEENTRY)(lpLogPal->palPalEntry));
// Create the palette.
hPal = CreatePalette(lpLogPal);
// Clean up.
GlobalFree(lpLogPal);
ReleaseDC(NULL, hDC);
return hPal;
}
// Create a 24-bit-per-pixel surface.
HBITMAP Create24BPPDIBSection(HDC hDC, int iWidth, int iHeight)
{
BITMAPINFO bmi;
HBITMAP hbm;
LPBYTE pBits;
// Initialize to 0s.
ZeroMemory(&bmi, sizeof(bmi));
// Initialize the header.
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = iWidth;
bmi.bmiHeader.biHeight = iHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
// Create the surface.
hbm = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pBits, NULL, 0);
return(hbm);
}
// Print the entire contents (including the non-client area) of
// the specified window to the default printer.
BOOL PrintWindowToDC(HWND hWnd)
{
HBITMAP hbm;
HDC hdcPrinter;
HDC hdcMemory;
HDC hdcWindow;
int iWidth;
int iHeight;
DOCINFO di;
RECT rc;
DIBSECTION ds;
HPALETTE hPal;
// Do you have a valid window?
if (!IsWindow(hWnd))
return FALSE;
|
|
|
|