|
You need to override the DrawItem function to handle your own drawing.
There are many owner-drawn buttons that have bitmap support here already, e.g. CButtonSSL, which I wrote It would only take a few small changes to prevent the focus rectangle being drawn (just comment out the call to DrawFocusRect ).
Derek Lakin.
Salamander Software Ltd.
|
|
|
|
|
Hi
thanks for the tips but it's a big implementation for something so simple. I did'nt find what I'm searching for but I will. This is for a commercial application, in fact a application that we sold whit hardware, but this application will need modification/update very often, the reason why I'm doing it now (and i'm not using the old one) it's because modification/update are too hard. So I want to minimize the code. I'm doing a scroll bar derived from CWnd to get strange functionality, and I'm doing the little arrow at each end of my scroll bar. For these button, I don't want any Focus rect, everything else work already very well whitout so much code.
So I don't want add a big button class when CButton do already the job very well, except for that f*** focus rect.
Remi Morin
Rmorin@Operamail.com
Remi.Morin@Lyrtech.com
|
|
|
|
|
Dumb question from a beginer.. Whats the advantage of using this on your strings?
Rob Jones
|
|
|
|
|
if you use this, when you switch from non-Unicode to Unicode builds, your string constants will convert accordingly.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I want to add items to a tree which have incremental numerical labels, how can I do this?
I want my items to consist of the CString "Section" + the short value generated by a FOR loop.
i.e. "Section 0"
"Section 1"
......
"Section 120"
Please help!
Pete T
|
|
|
|
|
see one of the following:
CString::Format
sprintf
itoa
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
My money in CString::Format
Carlos Antollini.
|
|
|
|
|
Hi,
I'm currently using some code that I found in the forum to write a file to a database and it almost works. It appears that I have some memory leaks that I can't seem to find. Following is the code I'm using which is in a loop. I loop through a directory of images so I can load them into a database.
CFile tmpFile(fileName, CFile::modeRead);
LONG nTotalBytes = tmpFile.GetLength();
BYTE * inputBuf = new BYTE[nTotalBytes];
UINT nBytesRead = tmpFile.Read(inputBuf, nTotalBytes);
CLongBinary cx_LongBinaryImage;
cx_LongBinaryImage.m_dwDataLength = nTotalBytes;
BYTE* pITemp = (BYTE*) GlobalLock(cx_LongBinaryImage.m_hData);
memcpy(pITemp, inputBuf, nTotalBytes);
GlobalUnlock(cx_LongBinaryImage.m_hData);
CImageRs* cxTableImage = new CImageRs();
if (cxTableImage->Open(NULL))
{
cxTableImage->AddNew();
cxTableImage->m_MAKE = "Yamaha";
cxTableImage->m_MODEL = "YZF600RK/RKC";
cxTableImage->m_YEAR = 1998;
cxTableImage->m_NAME = FindFileData.cFileName;
cxTableImage->m_IMAGE.m_dwDataLength = cx_LongBinaryImage.m_dwDataLength;
cxTableImage->m_IMAGE.m_hData = cx_LongBinaryImage.m_hData;
cxTableImage->SetFieldNull(&cxTableImage->m_IMAGE, FALSE);
cxTableImage->SetFieldDirty(&cxTableImage->m_IMAGE, TRUE);
if(!cxTableImage->Update())
{
AfxMessageBox( "Record not added; no field values were set." );
}
cxTableImage->Close();
}
delete[] inputBuf;
If I call GlobalFree on cx_LongBinaryImage.m_hData I get an error because the CLongBinary calls GlobalFree in it's destructor. Also, when I run this code in the loop I get an error, "Could not update; currently locked by user 'admin' on machine 'MYMACHINE'." This happens when the loop is halfway through the directory, I'm not sure why this is happening. I'm currently developing on Win2000 with VC++ 6.0.
Thanks for any help you can provide,
Craig
|
|
|
|
|
I don't see a delete of cxTableImage ?
|
|
|
|
|
Tim,
Thanks for the reply, that's what it was. Sorry for the trouble on such a simple mistake.
Thanks again,
Craig
|
|
|
|
|
Why is it always easier to see the other guys bug?
|
|
|
|
|
How can i register a .dll or .ocx file in my program similar register it using regsvr32.exe?
is using the DllRegisterServer() function,which dll file will i load when i use the function?
|
|
|
|
|
You can find the answer somewhere in this forum.
There was some example-code in a thread in the last few days.
Search the Topics and Replies, then you'll find the code
regards
|
|
|
|
|
That might have been me..
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=55401&tid=55395#xx55401xx
|
|
|
|
|
I want to retrieve icon like "my documents" in explorer but ...
My init function:
CShellUtil::CShellUtil()
{
SHFILEINFO shFinfo;
HIMAGELIST hImgList = NULL;
LPITEMIDLIST itemlist = 0;
bError=FALSE;
if (SHGetSpecialFolderLocation(0,
SIDL_DESKTOP , &itemlist) == NOERROR)
{
hImgList = (HIMAGELIST)SHGetFileInfo((LPCTSTR)
itemlist, 0, &shFinfo,
sizeof(shFinfo ),
SHGFI_SYSICONINDEX |
SHGFI_PIDL |
SHGFI_SMALLICON );
if(!hImgList)
{
bError=TRUE;
return;
}
m_SysImgList.m_hImageList=hImgList;
}
else
{
bError=TRUE;
return;
}
Function to display icon into Tree
HTREEITEM CShellUtil::AddSpecialItem(HTREEITEM hParent, int nFolder)
{
SHFILEINFO shFinfo;
int iIcon;
BOOL bIsCDROM=FALSE;
HTREEITEM hItem;
LPITEMIDLIST pIDL;
LPMALLOC pMem;
if(SHGetSpecialFolderLocation(NULL, nFolder, &pIDL) == NOERROR)
{
if(SHGetFileInfo((LPCTSTR)pIDL, 0, &shFinfo, sizeof(shFinfo),
SHGFI_DISPLAYNAME | SHGFI_PIDL |
SHGFI_ICON | SHGFI_SMALLICON))
{
if(SHGetMalloc(&pMem)==NOERROR)
{
pMem->Free(pIDL);
pMem->Release();
}
}
}
Icon = shFinfo.iIcon;
hItem=m_TreeCtrl.InsertItem(_T("Test"), iIcon, iIcon, hParent);
return hItem;
}
When i call 'AddSpecialItem', it's OK to insert special folder
from "CSIDL_DESKTOP" to "CSIDL_STARTMENU" and
from "CSIDL_DESKTOPDIRECTORY" to "CSIDL_LOCAL_APPDATA"-> DislplayName and Icon are OK
But there is a problem from "CSIDL_MYDOCUMENTS" to "CSIDL_MYVIDEO"
No icon and no display name and SHGetSpecialFolderLocation(..) return an error
I try with
if(SHGetFolderLocation(NULL, nFolder, NULL, 0, &pIDL) == S_OK)
but no success (return E_INVALIDARG)
I use lib from microsoft SDK august 2001 on win2000 Sp2 plateform with visual sp5
Please help
|
|
|
|
|
Hi
I want to write some short options directly into my executable. They should be appended at the end
of the exe (comparable to the ID3tag in MP3files).
I know how to open files in binary and write/read to/from them.
My question:
Is it possible to write the information into my executable while it is running?
Or do I need to temporarily create a copy, write it into this file and then delete original file?
thanks in advance
|
|
|
|
|
You want to write data directly into your executable?! Really? Since MP3 files are data files, it's up to the program that uses them to define where the data goes. But I don't think you can guarantee you'll know where your compiler will put its binary data without delving into the details of the PE format.
I would suggest you create a binary resource in your executable that just contains the options you need. You can then load the values using the standard LoadResource calls.
When you need to update the resource, you can use the BeginUpdateResource, UpdateResource and EndUpdateResource functions to do so, without having to worry about copying and deleting your executable.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
I HAVE done this before, a long time ago and remember having no end of problems with it, although at this point I would have to dig out the program to say exactly what they were. At this point in time, I would say it's a probably a very bad idea, and almost certainly unnecessary. (When I did it I was writing for the DOS platform, and we didn't have binary resources.)
Quite frankly doing anything with a running executable anymore is just asking for trouble. I have yet to find a "nice" way to delete a running executable from within it, let along anything more complex (Yes, I've seen numerous solutions to this problem, but they all smack of "dirty hacks" to me."
Assuming you're programming for Windows, resources ARE probably your best bet.
As far as binary resources go, I use a CFile derived wrapper class which encapsulates the Win32 resource handling calls and makes the resource(s) look just like disk files. Mine came out of a commercial code library (Dundas Ultimate Toolbox) but Code Project or Code Guru might have something similar (it's worth a look).
Probably not much help, but there it is...
Gamaliel Masters
"If I were to disprove 'I think, therefor I am', would I cease to exist?"
|
|
|
|
|
Hello,
Where can i find information in order to access data in an
*.mdb file using a console application under VC++6.0.
(I will need I/O access).
Thanks for help.
|
|
|
|
|
Try this:
http://msdn.microsoft.com/library/en-us/daosdk/html/dadidx01_3inr.asp?frame=true
or
http://msdn.microsoft.com/library/en-us/daosdk/html/davcsdk_5jcf.asp?frame=true
Martin
|
|
|
|
|
You have some options, that depends of wich technology you want to use.
For example you can use DAO, for that you have the CDAODatabase, CDAORecordset, etc, classes. You can use CDatabase Class usin ODBC, or you can use ADO, or OLE DB, for those you can find a lot of article in this site....
Good Luck!!!
Carlos Antollini.
|
|
|
|
|
hello !
when i try to debug my application, the following message appear to the
output window :
`First-chance exception in Democreator.exe (GDI32.DLL): 0xC0000005: Access Violation`
What does it mean ?
Thanks.
F.Julien
|
|
|
|
|
|
From MSDN:
<br />
First and Second Chance Exception Handling <br />
<br />
Microsoft Win32 Application Programming Interface (API) included with: <br />
<br />
<br />
- Microsoft Windows NT versions 3.1, 3.5, and 3.51<br />
- Microsoft Windows 95 version 4.0<br />
<br />
<br />
Structured exception handling (SEH) takes a little getting used to, particularly when debugging. It is common practice to use SEH as a signaling mechanism. Some application programming interfaces (APIs) register an exception handler in anticipation of a failure condition that is expected to occur in a lower layer. When the exception occurs, the handler may correct or ignore the condition rather than allowing a failure to propagate up through intervening layers. This is very handy in complex environments such as networks where partial failures are expected and it is not desirable to fail an entire operation simply because one of several optional parts failed. In this case, the exception can be handled so that the application is not aware that an exception has occurred. <br />
<br />
However, if the application is being debugged, it is important to realize that the debugger will see all exceptions before the program does. This is the distinction between the first and second chance exception. The debugger gets the "first chance," hence the name. If the debugger continues the exception unhandled, the program will see the exception as usual. If the program does not handle the exception, the debugger will see it again (the "second chance"). In this latter case, the program normally would have crashed had the debugger not been present. <br />
<br />
If you do not want to see the first chance exception in the debugger, then disable the feature. Otherwise, during execution, when the debugger gets the first chance, continue the exception unhandled and allow the program to handle the exception as usual. Check the documentation for the debugger that you are using for descriptions of the commands to be used. <br />
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Its a M$ known problem, It only Occurs in Win95 or Win98 - Best thing is to ignore it, as long as its not crashing your APP
|
|
|
|
|