|
Today, we have an informational dialog where the information is displayed in
a RichText control. The only action for the user is to press the OK button
to dismiss the dialog.
My desire is to enhance this dialog by adding a 'Go To' button where the
user would select one of the informational items in the list, press the 'Go
To' button, the dialog would disappear, and then the 'go to' action occurs.
I still need to display the information using RichText.
Following an example, I attempted to create a custom CListBox control where
the items in the listbox would be displayed using the CRichTextCtrl. The
custom CListBox control contains owner methods of DrawItem and MeasureItem.
The first draft for DrawItem is included. This code appears to work but is
far from perfect. It lacks code for item selection and in my sample code I
can get it to write outside of the boundary of the control. Furthermore, I
am not sure what needs to be done for MeasureItem method.
void CRichEditListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle (lpDrawItemStruct->hDC);
if (lpDrawItemStruct->itemID != -1)
{
COLORREF TextBkClr = SysColor (COLOR_WINDOW);
CString Text;
GetText (lpDrawItemStruct->itemID, Text);
CRect rect;
GetItemRect (lpDrawItemStruct->itemID, rect);
// Format the text and render it
UINT Left = ::MulDiv (rect.left, 1440, pDC->GetDeviceCaps (LOGPIXELSX));
UINT Top = ::MulDiv (rect.top, 1440, pDC->GetDeviceCaps (LOGPIXELSY));
UINT Right = ::MulDiv (rect.right, 1440, pDC->GetDeviceCaps (LOGPIXELSX));
UINT Bottom = ::MulDiv (rect.bottom, 1440, pDC->GetDeviceCaps (LOGPIXELSY));
CRect Rect (Left, Top, Right, Bottom);
FORMATRANGE fr;
fr.hdc = pDC->m_hDC;
fr.hdcTarget = pDC->m_hDC;
fr.rc = Rect;
fr.rcPage = Rect;
fr.chrg.cpMin = 0;
fr.chrg.cpMax = -1;
UINT StreamType;
if (Text.Left (6) == "{\\rtf1")
StreamType = SF_RTF;
else
StreamType = SF_TEXT;
EDITSTREAM es =
{
(DWORD)&Text, 0, EditStreamCallBack
};
m_pRichEditTemp->SetSel (0,-1);
m_pRichEditTemp->SetBackgroundColor (FALSE, TextBkClr);
m_pRichEditTemp->Clear ();
m_pRichEditTemp->StreamIn (StreamType, es);
m_pRichEditTemp->FormatRange (&fr, TRUE);
// Update the display with the new formatting
CRect rcClient;
m_pRichEditTemp->GetClientRect (&rcClient);
m_pRichEditTemp->DisplayBand (&rcClient);
}
}
I have examined the internet and information is scarce. My hope is that
some one can point me in the correct direction or can suggest another
approach.
Thank you for your support.
Dan
|
|
|
|
|
Hy.My problem is i dont know how to make gif animation in dynamic way with CxImage.
I found a static solution in the MFC demo program,but i need a dynamic one,
to allocate the memory dynamic.
thanx the help
|
|
|
|
|
Hi All,
I have a small app that is designed to open an Access database file (.mdb) from a normal CFileDialog. Each database has one table and has the exact same fields in it. My question is how can I open a CDatabase and connect to the CRecordset with any of the database files I select? When I created the new CRecordView and CRecordset a blank default .mdb file was used via ClassWizard.
If the default sql string is empty the "Select Database" dialog appears, but I want to select a database from my apps menu handler.
I have a CRecordView derived class (CEditorView) that will edit (add, delete, etc) the records. Unfortunately, most of the tutorials are for "reading" records only.
Hope this make sense. Thanks.
Mark
|
|
|
|
|
Take a look at this for classes to allow you to read and write to databases. There are also examples on how to edit records.
|
|
|
|
|
Thanks, but I am using ODBC:CRecordset/CDatabase for this app.
Mark
|
|
|
|
|
Mark F. wrote: My question is how can I open a CDatabase and connect to the CRecordset with any of the database files I select?
You'll want to use a DSN-less connection. This article shows a brief example.
Mark F. wrote: I have a CRecordView derived class (CEditorView) that will edit (add, delete, etc) the records. Unfortunately, most of the tutorials are for "reading" records only.
Editing/adding/deleting is no big deal. Just use CRecordset 's methods. For example:
rs.m_pDatabase->BeginTrans();
TRY
{
rs.Open();
rs.AddNew();
rs.var1 = 123;
rs.var2 = "Name";
...
rs.Update();
rs.m_pDatabase->CommitTrans();
}
CATCH(CDBException, pDBException)
{
rs.m_pDatabase->Rollback();
}
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
David,
I will read the article you posted. Thanks for the help!
Mark
|
|
|
|
|
Hi,
I need a virtual 'Video Capture Source'. I could make use of DirectX Filter to create a video capture source. But i am not getting how it is implemented in VC++. Can any example or link provide way to Register Filter created in VC++ as 'Video Capture Sources'
Thanks,
Jariwala Vishal
-- modified at 23:28 Thursday 10th November, 2005
|
|
|
|
|
Hi everybody. I stumbled today on a rather intriguing issue. I got a DLL which is loaded via a hook in Explorer.exe. In that DLL I got the following HFONT array.
#pragma bss_seg("Share")<br />
<br />
HFONT *hfntarrLabels;<br />
<br />
#pragma bss_seg()
I need it in a #pragma 'cause I use another application to set its elements. Anyway... the problem is that when I try to clean it up, free the memory, explorer.exe crashes. This is how I create it, before hooking:
hfntarrLabels = new HFONT[10];<br />
hfntarrLabels[0] = CreateFont(...)
And this is how I free it, during the hooking:
delete []hfntarrLabels; // <-- crashes
And this, also crashes:
SelectObject(hdcMem, hfntarrLabels[0]);
Even though as far as I can see, the hfntarrLabels[0] has a non zero value.
Ideas anybody?
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote: hfntarrLabels = new HFONT[10];
hfntarrLabels[0] = CreateFont(...)
From the code, it looks like you are allocating memory in one process and trying to access it from another. If that's the case, it's not going to work, since each process has its own virtual address space and an address in one is meaningless to another.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
But I'm using #pragma. Wasn't that supposed to fix such issues? Sorry, I'm a bit of a beginner in this memory allocation business ::- D. Anyway... I tried at least 10 combinations and it crashes and crashes and crashes all the time. I'm going nuts here ::- (. Explorer.exe just won't let me delete (free) an array I created before and crashes. Even if I created it from my DLL Loader process, it's still the same DLL right? It gets attached to Explorer.exe.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
I'm no expert in #pragma directives, but a quick Google search showed that
#pragma data_seg("SHARED")
is the right way to share *data* between applications loading the same DLL.
Axonn Echysttas wrote: Even if I created it from my DLL Loader process, it's still the same DLL right? It gets attached to Explorer.exe.
It's the same DLL, but it gets mapped to different address spaces everytime it's loaded by a process. In short, a memory addresses are specific to a process, so calling new in one process and delete on the other will definitely result in a crash.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Can some one tell me steps to be taken to rename a project.
|
|
|
|
|
As far as I remember, for VC++ 6 Rename your DSW file and your DSP file. If the environment asks you for the location of the DSP file upon loading the DSW, simply browse for it and then save all files. For .Net, might be the same but I'm not sure. You might need to rename the cppproj file. Hope that helps.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Assuming your project name is "blah", open up BLAH.DSP and BLAH.DSW in your favourite text editor and go to the first line on the DSP file, which will look like:
# Microsoft Developer Studio Project File - Name="blah" - Package Owner=<4>
Then do a global + all files search'n'replace for the string "blah" with the name of your new project (let's try "halb"). Save and exit. Then rename BLAH.* to HALB.* at the command prompt (you *are* using a good one like 4NT, aren't you? ) and away you go. Take 20 seconds and works.
|
|
|
|
|
HI all ,
Are there any restrictions (size wise) when using this function
my bouncechecker screams when the size of the sent buffer is greater then 6648 bytes
anyone ?
thanks
|
|
|
|
|
ita_cas wrote: bouncechecker
what's that ?
looking at the MSDN[^], i cannot see any restriction of this type...
maybe you overrun your buffer ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
He means BoundsChecker, a tool manily used for checking memory usage in an application.
BoundsChecker has saved me more than once...
|
|
|
|
|
|
Hi This is Fresh programer in VC++ ,So can any one give me a brief discription , how to write a code to make it run in service mode..
Dilip
|
|
|
|
|
come on some one reply me please.....
Dilip
|
|
|
|
|
|
I am trying to obtain a file path from handle in Windows NT driver. The PFILE_OBJECT->FileName contains only the path such as "\directory\file.ext" but not the device name or drive letter. How do i obtain the device name (drive letter) for the file?
I think there could be a way throught the PFILE_OBJECT->DeviceObject, but can't dig out from the DDK documentation how to get the name of this device.
Thanx
viliam
|
|
|
|
|
Hi
I want a MFC application in which I want to scroll some text. Also sometime text might be long and sometimes it might be short. Also Font size of text might need to be as big as 200. So is there a way to do it ?
I tried using CBannerStatic example given in this site, but problem occurs when i make my text size big. It stops scrolling and consumes 100% CPU making other application work very very slow.
So I want to make it myself and text shold scroll smothly without any flickering.....is there a way to do this ?
Thankx a lot in advance
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
still on the same problem since more than one month ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|