KwikStrip rewrite

Stuff you want Bio to see. [Home]

Moderator: BioHazard

User avatar
BioHazard
Posts: 408
Joined: Mon Jul 25, 2005 10:02
Location: Middle of California where there is no air.
Contact:

Post by BioHazard »

I have tried to figure out hotkeys but my tests have never worked. If someone wants to give me a C way to do hotkeys I'd be very much obliged.
If you can get the KwikStrip window in focus, you can open/close it with space.


I was asking about the dragging stuff because I'm going to rewrite KwikStrip again. The current version is extremly hacky but I know how to fix that now (using code from ZDL). I would keep the drawing functions though, as they are fine.
QBasicer
Posts: 22
Joined: Sun Nov 13, 2005 23:18

Post by QBasicer »

I can write a program to send a message to KwickStrip whenever a key combination is pressed. Actually, I might be able to merge the hook and KwikStrip together, but I'm not entirely sure. Hooking is a complex process. I have made programs the responded to hotkeys. Basically I told (XP!) that I wanted to listen in on what keys were pressed, and then I just filtered the keys I wanted. (Remember AccountLockout anybody? WinkeyLogout or something like that used this tech.)

EDIT: Is also "Stay on top" an option? I'd actually use if it had that. Actually, if it did the hotkey thing, I'd use it.
User avatar
BioHazard
Posts: 408
Joined: Mon Jul 25, 2005 10:02
Location: Middle of California where there is no air.
Contact:

Post by BioHazard »

Always on top is an option in the latest alpha.

I'm reading the MSDN page on WM_SETHOTKEY again. See if I missed something the last 5 times I read it.

EDIT: Problem solved:

Code: Select all

LRESULT CALLBACK MainProc(HWND dlg,UINT msg,WPARAM wp,LPARAM lp){
	switch(msg){
		case WM_CREATE:RegisterHotKey(dlg,1,MOD_CONTROL|MOD_ALT,'K');break;
		case WM_HOTKEY:SetForegroundWindow(dlg);break;
		case WM_CLOSE:PostQuitMessage(0);break;
	}return DefWindowProc(dlg,msg,wp,lp);
}
killingblair
Posts: 20
Joined: Wed Jul 06, 2005 14:04
Location: Oxford, PA

Post by killingblair »

Wow, you have an... intresting programming style Bio. ;)

I would have done it:

Code: Select all

LRESULT CALLBACK MainProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) {
   switch(msg)
{
      case WM_CREATE:
      RegisterHotKey(dlg, 1, MOD_CONTROL | MOD_ALT, 'K');
      break;

      case WM_HOTKEY:
      SetForegroundWindow(dlg);
      break;

      case WM_CLOSE:
      PostQuitMessage(0);
      break;
}
return DefWindowProc(dlg, msg, wParam, lParam);
}
For the sake of legibility. :P
Last edited by killingblair on Thu Jan 26, 2006 22:37, edited 1 time in total.
User avatar
DoomRater
Posts: 397
Joined: Tue Jul 19, 2005 4:14
Location: Programmer's Room, talking to Will Harvey
Contact:

Post by DoomRater »

Normally C code has each command written on each line.

Code: Select all

LRESULT CALLBACK MainProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ 
   switch(msg) 
  { 
      case WM_CREATE:
      RegisterHotKey(dlg, 1, MOD_CONTROL | MOD_ALT, 'K'); 
      break; 

      case WM_HOTKEY:
      SetForegroundWindow(dlg); 
      break; 

      case WM_CLOSE:
      PostQuitMessage(0); 
      break; 
   } 
   return DefWindowProc(dlg,msg,wp,lp); 
} 
To be honest though I like Bio's code much more.
User avatar
TheDarkArchon
Posts: 1000
Joined: Wed Jul 06, 2005 11:58
Location: What's that fucking smell
Contact:

Post by TheDarkArchon »

I'll quote Graf here: Compilers have optimizers for a reason.
User avatar
DoomRater
Posts: 397
Joined: Tue Jul 19, 2005 4:14
Location: Programmer's Room, talking to Will Harvey
Contact:

Post by DoomRater »

To me it seems that those three pieces of code belong on the same line, since they're all related to each other. It's like wiritng a paragraph.
User avatar
BioHazard
Posts: 408
Joined: Mon Jul 25, 2005 10:02
Location: Middle of California where there is no air.
Contact:

Post by BioHazard »

I was working on KS2.5 and I got bored.

http://biohazard.drdteam.org/temp/blob.zip
User avatar
Enjay
Developer
Developer
Posts: 4720
Joined: Tue Aug 30, 2005 23:19
Location: Scotland
Contact:

Post by Enjay »

He he, thanks. That was a real PIA on my mainly black desktop. ;)
User avatar
DoomRater
Posts: 397
Joined: Tue Jul 19, 2005 4:14
Location: Programmer's Room, talking to Will Harvey
Contact:

Post by DoomRater »

Might be useful to help decorate a Serenade desktop... sinc Serenade don't have any desktop icons to cover.
User avatar
BioHazard
Posts: 408
Joined: Mon Jul 25, 2005 10:02
Location: Middle of California where there is no air.
Contact:

Post by BioHazard »

Make fun of Bio's code!

Leson 2:

Code: Select all

 ////////////////////////////////////////////////////
// Strip_OpenClose : Opens and closes the strip (duh)
void Strip_OpenClose(){
	signed short i=(vr.open)?vr.rct.x:vr.rct.x+(vr.rct.w-mx.arww);
	signed short dest=(vr.open)?vr.rct.x+(vr.rct.w-mx.arww):vr.rct.x;
	signed char step=(vr.open)?(mx.btnw/4):(-(mx.btnw/4));
	if(cfg.anim){ // only animate if animation is turned on
		for(i;(vr.open)?i<=dest:i>=dest;i+=step){
			SetWindowPos(vr.strip,0,i,vr.rct.y,(vr.rct.w+vr.rct.x)-i,vr.rct.h,SWP_NOZORDER);
			UpdateWindow(vr.strip);
			Sleep(1);
		}
	}SetWindowPos(vr.strip,0,dest,vr.rct.y,(vr.open)?mx.arww:vr.rct.w,vr.rct.h,SWP_NOZORDER);
	vr.open=(vr.open)?(0):(1);
	SendMessage(vr.arw,WM_PAINT,0,0); // Change the arrow position
}
User avatar
TheDarkArchon
Posts: 1000
Joined: Wed Jul 06, 2005 11:58
Location: What's that fucking smell
Contact:

Post by TheDarkArchon »

I don't thing there is need to declare the integers as signed as they're signed by default (Well, it's like that in VC+, anyway)
User avatar
BioHazard
Posts: 408
Joined: Mon Jul 25, 2005 10:02
Location: Middle of California where there is no air.
Contact:

Post by BioHazard »

I just wanted to be absolutely sure they are signed, in case the default changes for some reason.

I also tend to go through my code and change things to unsigned 'cause I hardly ever do signed arithmetic. Hopefully seeing that I made them signed will stop me.

Just protecting it. :P
User avatar
DoomRater
Posts: 397
Joined: Tue Jul 19, 2005 4:14
Location: Programmer's Room, talking to Will Harvey
Contact:

Post by DoomRater »

What's a Question Mark mean in C++? That's the only thing I don't really know.
User avatar
BioHazard
Posts: 408
Joined: Mon Jul 25, 2005 10:02
Location: Middle of California where there is no air.
Contact:

Post by BioHazard »

Inline conditionals! \o/

(condition)?(true):(false)

So basically,

Code: Select all

vr.open=(vr.open)?(0):(1);
is a quicker way of saying

Code: Select all

if(vr.open){
    vr.open=0;
}else{
    vr.open=1;
}
The cool thing about inline conditionals is you can put them in the middle of a function call. For example

Code: Select all

Dlg_ChangeButtonState(btn.dwn?1:0);
This would pass 1 to the function if btn.dwn is true and 0 otherwise.
Last edited by BioHazard on Sun Feb 05, 2006 22:43, edited 1 time in total.
Locked

Return to “Bio's Site-Place”