|
Joined: Mar 2003
Posts: 187
Vogon poet
|
OP
Vogon poet
Joined: Mar 2003
Posts: 187 |
Recently, I released a DLL http://www.mircscripts.org/comments.php?id=2357that takes advantage of the rich editbox feature of mIRC 6.14. At the point of my release, I was having trouble with a subclass issue, so a certain feature wasnt included. This feature was when someone presses 'control+b' the text turns bold, and 'control+u', the text becomes underlined. Tonite, I completed that feature in my proc, finally, heh. Except for a few minor issues. 1. When the control code is pressed, the following text becomes bold or underlined like it should, however, when the closing control code is pressed, for some reason 2-3 characters afterward are bold(if control+b is pressed), when they shouldnt be. I cant figure out why. 2. The backspace and arrow keys dont work in the richedit under the Proc. I cant figure out why either. Any assistance will help, here is the full proc: LRESULT CALLBACK RichProc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
{
switch(msg)
{
{
case WM_KEYDOWN:
if(wp == VK_CONTROL) {
cd++;
}
break;
case WM_KEYUP:
if(wp == 0x42 && cd !=0) {
if(!bc) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
SendMessage( hwnd, EM_GETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
cfm.dwMask = CFM_PROTECTED | CFM_BOLD;
cfm.dwEffects = CFE_BOLD;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
bc++;
cd--;
}
else if(bc != 0) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
cfm.dwMask = CFM_PROTECTED;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
bc--;
cd--;
}
}
else if(wp == 0x55 && cd !=0) {
if(!uc) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
SendMessage( hwnd, EM_GETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
cfm.dwMask = CFM_UNDERLINE;
cfm.dwEffects = CFE_UNDERLINE;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
uc++;
cd--;
}
else if(uc != 0) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
cfm.dwMask = CFM_PROTECTED;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
uc--;
cd--;
}
}
break;
case WM_DESTROY:
SubclassWindow(hwnd,NULL);
PostMessage(hwnd,WM_DESTROY,0,0);
break;
default:
int blah = Search(hwnd);
CallWindowProc(AllProcs[blah].procold,hwnd,msg,wp,lp);
break;
}
int blah = Search(hwnd);
return CallWindowProc(AllProcs[blah].procold,hwnd,msg,wp,lp);
}
return 0L;
}
EDIT: Added [[/b]code] [[/b]/code] tags.
Last edited by Hammer; 26/03/04 08:11 AM.
|
|
|
|
Joined: Mar 2003
Posts: 187
Vogon poet
|
OP
Vogon poet
Joined: Mar 2003
Posts: 187 |
|
|
|
|
Joined: Jun 2003
Posts: 994
Hoopy frood
|
Hoopy frood
Joined: Jun 2003
Posts: 994 |
on 1:paste:message: {
if (!you == click.the.word.code) { return }
indent code
}
sorry .. couldn't resist it 
I refuse to engage in a battle of wits with an unarmed person.
|
|
|
|
Joined: Jan 2003
Posts: 10
Pikka bird
|
Pikka bird
Joined: Jan 2003
Posts: 10 |
Two remarks: mIRC crashes because when it tries to call the RichEdit proc from your dll, it's too late : it's already been unloaded (see http://www.mircscripts.org/forums.php?cid=6&id=31468) Second remark, the Ctrl+B combination will never make it to the control, because mIRC handles it. Maybe Khaled could do something about this. Oh yeah, and third remark: catch key combos like this: case WM_KEYDOWN:
{
if (wp == _T('B') && GetAsyncKeyState(VK_CONTROL) < 0 ) {
the counter way is... bah, ugly. Hope it helped (Edit: typo)
Last edited by Rasqual; 29/03/04 03:51 PM.
|
|
|
|
Joined: Mar 2003
Posts: 187
Vogon poet
|
OP
Vogon poet
Joined: Mar 2003
Posts: 187 |
I'm sorry but you didnt understand what I said. mIRC doesnt crash with my proc. My DLL does not unload, I programmed it accordingly. My problems are: 1. When the control code is pressed, the following text becomes bold or underlined like it should, however, when the closing control code is pressed, for some reason 2-3 characters afterward are bold(if control+b is pressed), when they shouldnt be. I cant figure out why. 2. The backspace and arrow keys dont work in the richedit under the Proc. I cant figure out why either. Second remark, the Ctrl+B combination will never make it to the control, because mIRC handles it. Maybe Khaled could do something about this. Unfortunately youre wrong, everything works in order. Like I said, my proc works fine except for the above mentioned errors. and finally, your method of key-catching doesnt work. I tried that(along with many variations of it) for 4 days, and nothing. My way works properly for what I want to do.
Last edited by Soul_Eater; 29/03/04 04:50 PM.
|
|
|
|
Joined: Jan 2003
Posts: 10
Pikka bird
|
Pikka bird
Joined: Jan 2003
Posts: 10 |
To begin, sorry for the confusion. I tested with my method and Ctrl+B didn't seem to reach the Message loop, hopefully it works for you...
As for the keys not working... could the reason be you return 0 (= Message handled) for *all* WM_KEYDOWN messages, even if they don't correspond to a keybord shortcut? Try returning 0 only when you do handle the message.
For prob. 1 sorry I cannot help >.< !
|
|
|
|
Joined: Mar 2003
Posts: 187
Vogon poet
|
OP
Vogon poet
Joined: Mar 2003
Posts: 187 |
ok what should I be returning than, if not 0?
|
|
|
|
Joined: Jun 2003
Posts: 195
Vogon poet
|
Vogon poet
Joined: Jun 2003
Posts: 195 |
for messages you do not handle (or arguments to a particular message) you should always return the value returned by the original prcoedure. A simple return CallWindowProc(arrguments,here,...); will do it
Have Fun
|
|
|
|
Joined: Oct 2003
Posts: 12
Pikka bird
|
Pikka bird
Joined: Oct 2003
Posts: 12 |
you can look in the source of x-GUI, I made my own mIRC code parser for custom richedits, and I had no problems with it.
|
|
|
|
Joined: Mar 2003
Posts: 187
Vogon poet
|
OP
Vogon poet
Joined: Mar 2003
Posts: 187 |
OK, I now no longer have space, arrow key, backspace/enter key problems at all, however as I said before, for some reason after typing, 2-3 characters remain bold or underlined afterward. Here's my new proc:
LRESULT CALLBACK RichProc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
{
switch(msg)
{
{
case WM_KEYDOWN:
if(wp == VK_CONTROL) {
cd++;
}
break;
case WM_KEYUP:
if(wp == 0x42 && cd !=0) {
if(!bc) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
SendMessage( hwnd, EM_GETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
cfm.dwMask = CFM_PROTECTED | CFM_BOLD;
cfm.dwEffects = CFE_BOLD;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
bc++;
cd--;
}
else if(bc != 0) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
cfm.dwMask = CFM_PROTECTED;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
bc--;
cd--;
}
}
else if(wp == 0x55 && cd !=0) {
if(!uc) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
SendMessage( hwnd, EM_GETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
cfm.dwMask = CFM_UNDERLINE;
cfm.dwEffects = CFE_UNDERLINE;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
uc++;
cd--;
}
else if(uc != 0) {
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
cfm.dwMask = CFM_PROTECTED;
SendMessage( hwnd, EM_SETCHARFORMAT,
(WPARAM)SCF_SELECTION, (LPARAM)&cfm );
uc--;
cd--;
}
}
break;
case WM_DESTROY:
SubclassWindow(hwnd,NULL);
PostMessage(hwnd,WM_DESTROY,0,0);
break;
}
int blah = Search(hwnd);
return CallWindowProc(AllProcs[blah].procold,hwnd,msg,wp,lp);
}
int blah = Search(hwnd);
return CallWindowProc(AllProcs[blah].procold,hwnd,msg,wp,lp);
}
|
|
|
|
|