|
Yes you have to use CPen pen(..) and then pDC->SelectObject(pen);
don't forget to free resorces DeleteObject(pen)
because after some time our application my behave in funy way
Pain is a weakness living the body
|
|
|
|
|
CPen is for line drawing. You need to use CDC::SetTextColor(COLORREF) to choose what colour the text gets drawn in.
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Rafael Fernández López wrote:
but I can't see anything for the color...
Thats because the control's font has nothing to do with the colour being displayed.
One method that I use is to implement the WM_CTLCOLOR message handler, and set the draw colour (SetTextColor()) for all or individual static control.
Or you can use a derived label class like this: CLabel[^].
I Dream of Absolute Zero
|
|
|
|
|
Does anyone have a tutorial about adding C++ (Visual Studio) code as a macro in Excel. Need to know this for some job interviews. Thanks
|
|
|
|
|
That I know of, the macros used in Excel (and all of Office) are VBA (a derivative of VB), not C++.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Do you mean how to create a COM Add-in? Because Excell macros are VBA code, not C++, but if you are referring to Add-ins, your COM class must implement the IDTExtensibility2 interface in order to work with any MS Office program.
Do a search on the MSDN on IDTExtensibility2, also you can take a look to this article, Comaddin.exe Office 2000 COM Add-In Written in Visual C++, it is a Win32 project that you can use as starting point, but I suggest you to use ATL to help yourself with this task.
Fabian
|
|
|
|
|
Yes, this is it!! Thanks for your help.
Regards
Chris
|
|
|
|
|
Hi, I must get a string from a function included into a DLL, imported in a ASP.NET page.
The code:
----
Into a .aspx.cs page:
//def. function included into a DLL
[DllImport("WebUtility.dll", EntryPoint = "getDescr")]
public static extern string getDescr(int id);
//call the function:
string descr=getDescr(123);
---
into the c++ program, the function is definied as:
char* getDescr(int id) {
char* ret=new char[LUNGHEZZA_STRINGA_MEM];
strcpy(ret,oggetto[id].descr);
return (ret);
}
If I throw the application, the server give me the error: System.NullReferenceException: Object reference not set to an instance of an object.
But this error is generated not every time, but random!! some time I can view the string correctly! Why?
Thanks for the help!!!
|
|
|
|
|
You can try
[return: MarshalAs(UnmanagedType.LPStr)] However, that's going to be tricky: what frees the string?
If you control both the C# code and the DLL, I'd change your API so it takes a string pointer and a size:
BOOL GetDescr( int id, char* pBuffer, int bufLen )
{
if ( bufLen < LUNGHEZZA_STRINGA_MEM )
{
return FALSE;
}
else
{
strcpy( pBuffer, oggetto[id].descr );
return TRUE;
}
} then call from C# like so:
[DllImport( "WebUtility.dll", EntryPoint=GetDescr )]
public static extern bool UnsafeGetDescr( int id, StringBuilder buffer, int bufLen );
public static extern string GetDescr( int id )
{
StringBuilder sb = new StringBuilder( LUNGHEZZA_STRINGA_MEM );
if ( !UnsafeGetDescr( id, sb, sb.Capacity ) )
{
return null;
}
else
{
return sb.ToString();
}
}
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Ok, thank you vary much, using your suggestion I solved the problem!!
Matteo
|
|
|
|
|
Hi Friends,
Our product uses shell integration to extend the functionality of the explorer. when doing some internal operation i may get crash. Explorer then dies. Instead of try/catch in each functionality I need a generic solution so that i can do some cleanup at the time of crash.
(i)I tried with Hooking windows messages but i am not getting the quit/destroy message when the explorer crashes abrubtly(Terminate process)
(ii) I tried with some solutions in the internet for monitoring the process but it is complex with additional server / dll that is injected with all process. Also this solution causes performance difference.
Can any one of you please help me to find a simple solution so that i can handle this situation.
jothi
|
|
|
|
|
Have you tried some low level debuggers like softice or WinDBG?
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Thanks for your reply.
Sorry, I dont know the usage of these debuggers.
Can you please explain more details about that.
jothi
|
|
|
|
|
|
the vertical scroll bar doesnt get enabled if i add string which doesnt fit a list box. Any ideas what seems to be the problem here. Horizontal scroll bar seems to work fine.
m_lstboxMessages.AddString(sServerMsg);<br />
UpdateData(FALSE);
where m_lstboxMessages is control variable of CListBox
Any suggestion regarding this??
|
|
|
|
|
Make sure that the Vertical ScrollBar property of your control is enabled. You should be able to see this in the resource view.
I Dream of Absolute Zero
|
|
|
|
|
yea its enabled infact i should have mentioned the styles that i have turned on...
Border=checked
Horizontal Scroll=checked
Vertical scroll=checked
Disable No Scroll=checked
No integral height=checked
any thing missing over here??
|
|
|
|
|
FASTian wrote:
the vertical scroll bar doesnt get enabled if i add string which doesnt fit a list box.
This indicates that the horizontal scroll bar is not working. The vertical scroll bar is not concerned with a string's length. It comes into play when there are more items in the control than can be displayed (e.g., the control can only show 10 strings but 15 have been added).
If I am correct, it sounds like you simply need to call SetHorizontalExtent() in the dialog's OnInitDialog() method..
FASTian wrote:
m_lstboxMessages.AddString(sServerMsg);
UpdateData(FALSE);
There is no need to (ever) call UpdataData() .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
nopes thats not the case the horizontal bar shows correctly...
when i add a long string. It only shows a part of the string according to the vertical height i.e it just shows only the last 10 characters or something like that...
|
|
|
|
|
I think I understand, but a picture is worth 1,000 words. Can you provide one?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
any ideas how i can paste a pic over here???
|
|
|
|
|
You can't (that I know of). You'd need to upload one to your own Web site and provide a link for it here.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi
I am trying to print a CString to a file using C++ ofstream. What I do is something like this:
CString cstr = "This is a test";
std::ofstream fTest("TestCString.txt");
fTest << cstr;
fTest.close();
The problem is, the result in TestCString.txt is not the text "This is a test", instead it is something like 002F4BC4, which I couldn't make any sense out of it.
Could someone tell me what the problem is, and since the string in my project MUST use CString, is there a way to print it using ofstream without changing the CString class?
Thanks!
|
|
|
|
|
try
CString cstr = "This is a test";
std::ofstream fTest("TestCString.txt");
fTest << (LPCTSTR)cstr;
fTest.close();
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
fTest << (LPCTSTR)cstr;
TOXCCT >>> GEII power
|
|
|
|