|
Hi all,
I am using VS.NET 2005, and MFC.
I've created a drived class CMyRichEditCtrl (derives from CRichEditCtrl)
in my init instance of the dialog based application i call : "AfxInitRichEdit2()" (as should be!)
I've dragged a rich edit control into my dialog and in the ddx i gave it a control name (m_MyEdit).
now, in the OnInitDialog i use:
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
GetSelectionCharFormat(cf);
cf.crTextColor = RGB(255,0,0);
SetSelectionCharFormat(cf);
m_Edit.SetWindowText(_T("This is a test"));
i can see the text but it is not colored???
same way i tried to change the text font :
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_SIZE;
cf.yHeight = 20 * 14;
_tcscpy(cf.szFaceName,_T("Tohoma"));
SetSelectionCharFormat(cf);
still nothing...just plain text...
what am i doing wrong?
thanks in advanced
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
You first need to set the text (using SetWindowText for example, as you did), then select the text that you want to format and call SetSelectionCharFormat for that selection. After this, you normally restore the selection to something normal, like no selection.
Example:
m_Edit.SetWindowText(_T("This is a test"));
m_Edit.SetSel(0, -1);
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
GetSelectionCharFormat(cf);
cf.crTextColor = RGB(255,0,0);
SetSelectionCharFormat(cf);
m_Edit.SetSel(0, 0);
Best regards
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
Hi,
How to stop a working thread which is busy in doing progress control work from User interface(UI) Thread ,That means close the working thread when i press a button
Thanking you
Manjunath S
GESL
Bangalore
|
|
|
|
|
Best method is to derive a class from CWinThread and design it to do all your work. Then add two messages:
#define WM_THREAD_START (WM_USER + number)
#define WM_THREAD_QUIT (WM_USER + number)
then add 2 handlers:
ON_THREAD_MESSAGE(WM_THREAD_QUIT, OnQuit)
ON_THREAD_MESSAGE(WM_THREAD_START, OnStart)
Start the thread:
m_pYourthread->CreateThread(CREATE_SUSPENDED,0,0)
m_pYourthread->ResumeThread();
This allows you to start and stop the thread simply by doing:
PostThreadMessage(m_pYourthread->m_nThreadID,WM_THREAD_START,0,0)
or
PostThreadMessage(m_pYourthread->m_nThreadID,WM_THREAD_QUIT,0,0)
Best wishes,
-Randor
|
|
|
|
|
In the UI thread, you'll set a flag of some sort, and have the worker thread check it. You can use a message (as Randor suggested) providing you're pumping messages regularly in the worker thread. You could use an event object, or even just a global variable (which you might want to protect using a critical section). The important thing is that, whatever sort of flag you use, you design your worker thread in such a way that it gets checked periodically.
And yes, you can force a thread to stop execution programatically, but you really don't want to do this - it'll likely leave your application in an unknown and potentially dangerous state, to say nothing of the state it'll leave whatever it was working on.
|
|
|
|
|
Hi,
I have an application in which I am loading data from a database (in this specific case a large database) into a grid in my GUI. So, I open the query into a recordset using the Open method as follows:
sQuery.Format(_T("SELECT DISTINCT D.fieldA, DC.fieldB
from TableDC DC, TableD D
WHERE D.fieldA = DC.fieldA AND D.No = '3’
ORDER BY DC.fieldB"));
if(!Open(AFX_DB_USE_DEFAULT_TYPE, sQuery, CRecordset::readOnly))
{
...
}
The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok).
Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
|
|
|
|
|
SWDevil wrote: The problem is that the statement that contains the call to the Open method sometimes takes about 2 minutes to execute (and sometimes works ok).
Anyone have any idea of why this happens? And maybe an idea of how I can fix it (speed it up)?
This may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..as well as its a ORDER query so it takes time to fetch the fields and sorting as well.
Knock out 't' from can't,
You can if you think you can
|
|
|
|
|
A_LaxmanThis may due to your DataBase doing some pending work..or your request is not scheduled by the Database engine..
can I somehow check if this happens and if it does, can I fix it?
A_Laxmanas well as its a ORDER query so it takes time to fetch the fields and sorting as well.
but this same query sometimes executes very quickly...
|
|
|
|
|
Hello everyone!
I've asked this before, but I'm still unable to solve it...
I have this string:
is730enu.exe.mtx
I want to copy only the first 12 characters of it, to another string. How do I do that, in C? (No C++) Thanks!
\|/ Thrift Store Floppy Collection \|/
(Server currently down due to mainteneance, aka comp not detecting monitor and acting weird)
|
|
|
|
|
And what was wrong with the previous solutions presented?
Since you don't seem to like the more general solutions presented, perhaps this is more specific to what you want?
<br />
int i;<br />
char mystring[13];<br />
char *str = "is730enu.exe.mtx";<br />
for(i = 0; i < 12; i++) mystring[i] = str[i];<br />
mystring[12] = '\0';
|
|
|
|
|
The function to copy N bytes is:
strncpy()
char string[]= "is730enu.exe.mtx";
char chopped[13];
strncpy (chopped,string,12);
chopped[12]='\0';
printf("%s\n",chopped);
However... I have a feeling that what your actually trying to do is extract the filename from the file extension. But your filename has two dots.
Here is how I would do it:
char string[]= "is730enu.exe.mtx"; //The string
char *p; //pointer to a character
p = strrchr(string,'.'); //Assign p to the memory location of the last dot
*p = '\0'; //change the character into a NULL
printf("%s\n",string); //print the original string
|
|
|
|
|
Oh... Sorry, hfry, I didn't get why the extra chars at the end, but now I see that you need to end it with the null character! Thanks now you both!
\|/ Thrift Store Floppy Collection \|/
(Server currently down due to mainteneance, aka comp not detecting monitor and acting weird)
|
|
|
|
|
I have alway use in Visual C++ 6.0:
int ivalue=0;
CString str=_T("0");
ivalue=atoi(str);
without any problem, but now in Visual Studio 2005 I get a error:
'atoi' : cannot convert parameter 1 from 'CString' to 'const char *'
? I do not understand !
AutreChien
|
|
|
|
|
You may be getting this because you are compiling your application for UNICODE.
Software Zen: delete this;
|
|
|
|
|
|
hi,
I have a class that is a general class and not derived from any classes.
I want send message to it when somthing was happen. but I don't know how?
please help me.
|
|
|
|
|
You have a number of options:
1) Implement your own callback mechanism.
2) Use more mature technique such Observer design pattern.
3) If you program in new C++/CLI, event model is a good notification mechanism to use.
- It's easier to make than to correct a mistake.
|
|
|
|
|
is there a solution to directly turn off a hard-disk?
I need such a small program for testing purposes!
Please help.
It should be as small as like that:
http://www.codeproject.com/system/display_states.asp
|
|
|
|
|
|
Hi guys
I get following error when running my program.
Run-Time Check Failure #2 - Stack around the variable 'Temp' was corrupted.
where 'Temp' is a pointer to a class.
Does anyone know what the source of this run time error is ?
regards
Mahdi
|
|
|
|
|
I am developing a flow-chart program which needs many nice and simple shapes, such as heart (or "I love u"), mushroom etc, and formulas to draw them.
do u know links which provide this kind of shapes and formulars?
thx
|
|
|
|
|
asked in an interview---
what is marshalling in c++, pls give me a small code example.
thanx in advance
kumar_windows
|
|
|
|
|
All data/variables that are passed as parameters to processes, or passed through contexts must have appropriate marshalling functions. These functions convert the data to and from a binary stream.
The passing of data and values after being converted to binary stream is called "marshalling".
Marshalling is acheived through the use of the classes mStream and umStream, which marshal and unmarshal data respectively.
The global functions:
mStream & operator<< (mStream & s, T const &v);
umStream& operator>> (umStream& s, T &v);
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
The term "marshalling" usually refers to COM; specifically when you make an object in one apartment accessible in another. See Here[^] for details.
Steve
|
|
|
|
|
Hi,
I have a bitmap file in memory, including the header. Now I would like to create a CBitmap/HBITMAP from it.
My problem is that LoadImage only loads a .bmp from a file, but not from a buffer.
CBitmap::CreateBitmapIndirect allows to create the CBitmap from a BITMAP structure, but unfortunately this structure is different from the bitmap header. The BITMAP structure also has no pointer to the color palette??
Is there a better way to load the bitmap than going through the header to find the data myself?
|
|
|
|