pomodoro源码
有网友问我要pomodoro源码。事实上这个程序非常easy,仅仅是定时器,定时弹出置顶窗体。用c++builder6.0写。放一个TPopupMenu 右键菜单,一个TTrayIcon 一个托盘图标控件
。一个ImageList1图片列表,显示闪动图片。显示时间的标签。
源码例如以下,假设不用C++builder写,仅仅能參考代码自己写。
定时器推断时间到了就显示窗体。闪动图标。双击关闭窗体。
unit1.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include "trayicon.h"
#include <Menus.hpp>
#include <ImgList.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TTimer *Timer1;
TLabel *LMinute;
TLabel *LMaohao;
TLabel *LSecond;
TTrayIcon *TrayIcon1;
TPopupMenu *PopupMenu1;
TMenuItem *N1;
TImageList *ImageList1;
TMenuItem *sinoxorg1;
TMenuItem *N2;
void __fastcall Timer1Timer(TObject *Sender);
void __fastcall N1Click(TObject *Sender);
void __fastcall FormDblClick(TObject *Sender);
void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
void __fastcall TrayIcon1Restore(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall sinoxorg1Click(TObject *Sender);
void __fastcall FormKeyPress(TObject *Sender, char &Key);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <registry.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "trayicon"
#pragma resource "*.dfm"
TForm1 *Form1;
int iWaitTime=0;
int MaxWaitTime=25*60;
int MaxRestTime=5*60;
int RunState=0;
int IsOwnerPress=false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
RunState=0;
IsOwnerPress=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
iWaitTime+=1;
if (RunState==0)
{
if ( iWaitTime>= MaxWaitTime)
{
RunState=1;
iWaitTime=0;
}
Color= clBtnFace;
LMinute->Color= clBtnFace;
LMaohao->Color= clBtnFace;
LSecond->Color= clBtnFace;
LMinute->Caption=iWaitTime/60;
LSecond->Caption=iWaitTime%60;
if ( iWaitTime%5==0)
{
if (WindowState!=wsMinimized)
{
WindowState=wsMinimized;
Hide();
}
}
IsOwnerPress=false;
TrayIcon1->Animate=false;
//randomize();
//TrayIcon1->SetIconIndex(rand() % 3);
TrayIcon1->SetIconIndex(1);
}
else
{
if ( iWaitTime>= MaxRestTime)
{
RunState=0;
iWaitTime=0;
IsOwnerPress=false;
}
Color= clRed;
LMinute->Color= clRed;
LMaohao->Color= clRed;
LSecond->Color= clRed;
LMinute->Caption=iWaitTime/60;
LSecond->Caption=iWaitTime%60;
if(IsOwnerPress)
{
if ( iWaitTime%5==0)
{
if (WindowState!=wsMinimized)
{
WindowState=wsMinimized;
Hide();
}
}
}
else
{
if (WindowState==wsMinimized)
{
WindowState=wsNormal;
Show();
}
TrayIcon1->Animate=true;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N1Click(TObject *Sender)
{
Application->Terminate();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDblClick(TObject *Sender)
{
WindowState=wsMinimized;
Hide();
IsOwnerPress=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
WindowState=wsMinimized;
Action=caNone;
Hide();
IsOwnerPress=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TrayIcon1Restore(TObject *Sender)
{
WindowState=wsNormal;
Show();
IsOwnerPress=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TRegistry *Test;
Test = new TRegistry ();
Test->RootKey = HKEY_LOCAL_MACHINE;
if(Test->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",false))
{
AnsiString sKeyval;
sKeyval=Test->ReadString("sinox_pomodoro");
if (sKeyval.Length()<=4)
Test->WriteString("sinox_pomodoro",Application->ExeName);
}
delete Test ;
randomize();
TrayIcon1->SetIconIndex(rand() % 3);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::sinoxorg1Click(TObject *Sender)
{
AnsiString strurl= "http://www.sinox.org/";
ShellExecute(NULL,NULL, strurl.c_str(),NULL,NULL,SW_SHOW);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
if (Key==VK_SPACE)
{
WindowState=wsMinimized;
Hide();
IsOwnerPress=true;
}
}
//---------------------------------------------------------------------------
unit1.dfm
object Form1: TForm1
Left = 192
Top = 114
Width = 870
Height = 145
BorderIcons = [biSystemMenu]
BorderStyle = bsSizeToolWin
Color = clBtnFace
DefaultMonitor = dmDesktop
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -24
Font.Name = ‘MS Sans Serif’
Font.Style = []
FormStyle = fsStayOnTop
OldCreateOrder = False
Position = poDesktopCenter
OnClose = FormClose
OnCreate = FormCreate
OnDblClick = FormDblClick
OnKeyPress = FormKeyPress
PixelsPerInch = 96
TextHeight = 29
object LMinute: TLabel
Left = 349
Top = 16
Width = 44
Height = 33
AutoSize = False
Caption = ‘0’
end
object LMaohao: TLabel
Left = 400
Top = 16
Width = 32
Height = 33
AutoSize = False
Caption = #65306
end
object LSecond: TLabel
Left = 440
Top = 16
Width = 57
Height = 33
AutoSize = False
Caption = ‘0’
end
object Timer1: TTimer
OnTimer = Timer1Timer
Left = 448
Top = 80
end
object TrayIcon1: TTrayIcon
Visible = True
Hint = #24037#20316#20241#24687#25552#37266#22120
PopupMenu = PopupMenu1
Hide = True
RestoreOn = imDoubleClick
PopupMenuOn = imRightClickUp
Icons = ImageList1
IconIndex = 1
OnRestore = TrayIcon1Restore
Left = 320
Top = 80
end
object PopupMenu1: TPopupMenu
Left = 88
Top = 72
object N1: TMenuItem
Caption = #20851#38381
OnClick = N1Click
end
object sinoxorg1: TMenuItem
Caption = #35775#38382’sinox.org’
OnClick = sinoxorg1Click
end
object N2: TMenuItem
Caption = #21452#20987’/’#25353#31354#26684#38544#34255
end
end
object ImageList1: TImageList
AllocBy = 3
Left = 200
Top = 80
Bitmap = {
494C010103000400040010001000FFFFFFFFFF00FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001002000000000000010
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000909E9003434
760032327C000405F60000000000000000000000000000000000000000003030
8300363671000909E900000000000000000000000000000000000909E9003434
760032327C000405F70000000000000000000000000000000000000000003030
8300363671000909E900000000000000000000000000000000000909E9003131
7700313177000505F60000000000000000000000000000000000000000003030
8300363671000909E90000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000002A2A95005354
21004E4C3100311D950029209E0031446E0031446E002B2597002F1B9A004E4C
31005354210030308300000000000000000000000000000000002A2A95005253
26004E4C2F0031218400282196002F4481002F4481002A2A95002F1A85004F4B
2F005253260030308300000000000000000000000000000000002A2A95005454
21004B4B33001D1D950021219E0042446E0042446E00252796001B1A9A004B4B
3300545421003030830000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000001012D600453D
54004B3E47002E95210011E9000009F9000009F9000011E9000027A819004844
4500473C4F001315CD00000000000000000000000000000000001112D500453D
4C004A3F3B002D96880013E5CD0008FAE90008FAE90010EBD30029A291004745
4100473C45001315CF00000000000000000000000000000000001212D6003C3C
50003C3C500095962000E4E50000FAFB0000FAFB0000E9EB0000A1A21A004445
45003C3C50001515CD0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000003831
780019CE0B0000FF000000FF000000FF000000FF000000FF000000FF000012DC
07003A4064000000000000000000000000000000000000000000000000003731
720018D0BF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0011DD
D00039416C000300F80000000000000000000000000000000000000000003131
7700CED00A00FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000DCDD
0600414164000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000002510B50025BF
090000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF
00001CD302002D1B9D000000000000000000000000000000000025109F0023C0
A30000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF
FF001AD5B8002C1C8D0000000000000000000000F8000000F8001010B500BFC0
0800FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF
0000D4D501001B1A9A0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000003457570000FF
000000FF000000FF000000FF000000FF000000FF000000FF000000FF000000FF
000000FF0000336F3F000900F80000000000000000000300F80033587A0002FF
F90000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FF
FF0000FFFF0032717B000800EB0000000000000000000000000057585600FFFF
0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF
0000FFFF00006F713E000000F8000000F8000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000F00EF002D8E2B0000FF
000000FF000000FF000000FF000019C1190021AD21000BE10B000BE10B000BE1
0B0000FF000027A819001400E20000000000000000000F00DB002B8B8E0000FF
FF0000FFFF0000FFFF0000FFFF001AC3B9001FAEAE000AE5E3000BDFDD000AE5
E30000FFFF0026AA9A001400CC0000000000000000000000EF008E8F2A00FFFF
0000FFFF0000FFFF0000FFFF0000C1C21700AEAE1F00E3E50A00DEDF0D00E2E4
0A00FFFF0000A8AA17000000E200000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000001100EA002A97240000FF
000000FF000000FF000000FF00002D8E2B003B663B001EB21E0021A721001EB2
1E0000FF000023B612001600DD0000000000000000001000D7002A97910000FF
FF0000FFFF0000FFFF0000FFFF002A979100396967001BB7B3001EADA8001BB7
B30000FFFF0022B8A6001600C60000000000000000000000EF0097992300FFFF
0000FFFF0000FFFF0000FFFF00009092290067693900B3B71B00A8AD1E00B3B7
1B00FFFF0000B6B811000000DD00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000900F8002E7E380000FF
000000FF000000FF000000FF00000CE30C000FDF0F0000FF000000FF000000FF
000000FF00002A9724000F00EF0000000000000000000A00E7002D84880000FF
FF0000FFFF0000FFFF0000FFFF000AE5E3000AE5E30000FFFF0000FFFF0000FF
FF0000FFFF002A9791001000D7000000000000000000000000007E803600FFFF
0000FFFF0000FFFF0000FFFF0000E2E40A00E2E40A00FFFF0000FFFF0000FFFF
0000FFFF0000979923000000EF00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000303083000DF8
000000FF000000FF000000FF00000FDF0F0012D6120000FF000000FF000000FF
000000FF0000314A6800000000000000000000000000000000002D348A000BF9
DF0000FFFF0000FFFF0000FFFF000DDFDE000FD7D60000FFFF0000FFFF0000FF
FF0007FFEC00304C82000000000000000000000000000000000030308300F8F9
0000FFFF0000FFFF0000FFFF0000DEDF0D00D6D70F00FFFF0000FFFF0000FFFF
0000FFFF00004A4C670000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000001C1DB7001C08CD002F82
340000FF000000FF000000FF00000FDF0F0012D6120000FF000000FF000000FF
00002A9D22001E07CB001C1DB70000000000000000001C1DB7001D07B4002D84
880000FFFF0000FFFF0000FFFF000DDFDE000FD7D60000FFFF0000FFFF0000FF
FF00299E93001D07B4001C1DB70000000000000000001E1EB2000707CD008384
3200FFFF0000FFFF0000FFFF0000DEDF0D00D6D70F00FFFF0000FFFF0000FFFF
00009D9E21000707CD001E1EB200000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000202F90043434F003F405800210B
C4002C89310009F9000000FF000008F7080009EE090000FF000008FF00002A9D
2200230FBB00343476004A4A3E000909E9000405F70043434F003F405800200B
AE002B8B8E0009FDE60000FFFF0004F4F30007EFED0000FFFF0007FFEC00299E
9300240FA700343476004A4A3D000909E9000505F60043434F00404058000B0B
C100898B3000FAFB0000FFFF0000EEEF0700EEEF0700FFFF0000FFFF00009D9E
21000F0FBB00313177004A4A3E000909E9000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000034347600535421003F40
5800210BC4002F4274002A9827001CBF13001CBF13002A9D2200314A6800210B
C4003A386A00535421003F4058000405F6000000000034347600535421003F40
5800200BAE0029428C00299E93001BC0B6001BC0B600299E93002E4F8700200B
AE003A386900535421003F4058000405F7000000000036367100545421004040
58000D0CC0004343730097992300BFC01100BFC011009D9E21004E4F67000B0B
C30038386A0054542100404058000505F6000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000909E90032327C003B3B
6400181AC100000000000F00EF003B277A003B277A001100EA00000000001012
D6003B3B6400343476000E0EDC0000000000000000000909E90032327C003B3B
6400181AC300000000000F00DB003B2866003B2866001000D700000000001112
D5003B3B6400343476000E0EDC0000000000000000000909E90032327C003B3B
64001A1AC100000000000000EF0028287900282879000000EF00000000001212
D6003B3B6400363671000E0EDC00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000708EE000708EE0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000708EF000708EF0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000808EE000808EE0000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000100000000100010000000000800000000000000000000000
000000000000000000000000FFFFFF00FFFFFFFFFFFF0000C3E3C3E3C3E30000
C003C003C0030000C003C003C0030000E007E003E0070000C003C00300030000
C0018001C00000008001800180010000800180018001000080018001C0010000
C003C003C0030000800180018001000000000000000000008000800080000000
8421842184210000FE7FFE7FFE7F0000}
end
end
能够建立一个项目后替换这三个文件。
pomodoro源码的更多相关文章
- 【原】Android热更新开源项目Tinker源码解析系列之三:so热更新
本系列将从以下三个方面对Tinker进行源码解析: Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Android热更新开源项目Tinker源码解析系列之二:资源文件热更新 A ...
- C# ini文件操作【源码下载】
介绍C#如何对ini文件进行读写操作,C#可以通过调用[kernel32.dll]文件中的 WritePrivateProfileString()和GetPrivateProfileString()函 ...
- 【原】FMDB源码阅读(三)
[原]FMDB源码阅读(三) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 FMDB比较优秀的地方就在于对多线程的处理.所以这一篇主要是研究FMDB的多线程处理的实现.而 ...
- 从源码看Azkaban作业流下发过程
上一篇零散地罗列了看源码时记录的一些类的信息,这篇完整介绍一个作业流在Azkaban中的执行过程,希望可以帮助刚刚接手Azkaban相关工作的开发.测试. 一.Azkaban简介 Azkaban作为开 ...
- 【原】Android热更新开源项目Tinker源码解析系列之一:Dex热更新
[原]Android热更新开源项目Tinker源码解析系列之一:Dex热更新 Tinker是微信的第一个开源项目,主要用于安卓应用bug的热修复和功能的迭代. Tinker github地址:http ...
- 【原】Android热更新开源项目Tinker源码解析系列之二:资源文件热更新
上一篇文章介绍了Dex文件的热更新流程,本文将会分析Tinker中对资源文件的热更新流程. 同Dex,资源文件的热更新同样包括三个部分:资源补丁生成,资源补丁合成及资源补丁加载. 本系列将从以下三个方 ...
- 多线程爬坑之路-Thread和Runable源码解析之基本方法的运用实例
前面的文章:多线程爬坑之路-学习多线程需要来了解哪些东西?(concurrent并发包的数据结构和线程池,Locks锁,Atomic原子类) 多线程爬坑之路-Thread和Runable源码解析 前面 ...
- SDWebImage源码解读之SDWebImageDownloaderOperation
第七篇 前言 本篇文章主要讲解下载操作的相关知识,SDWebImageDownloaderOperation的主要任务是把一张图片从服务器下载到内存中.下载数据并不难,如何对下载这一系列的任务进行设计 ...
- 【深入浅出jQuery】源码浅析--整体架构
最近一直在研读 jQuery 源码,初看源码一头雾水毫无头绪,真正静下心来细看写的真是精妙,让你感叹代码之美. 其结构明晰,高内聚.低耦合,兼具优秀的性能与便利的扩展性,在浏览器的兼容性(功能缺陷.渐 ...
随机推荐
- Oracle 整理
高效分页 select * from ( select rownum r,a from yourtable order by name ) --之所以没有把<=20放在最外面,也就是我一直用的写 ...
- cannot load shared object file undefined symbol
cannot load shared object file undefined symbol 场景: 共享库里引用了主程序一个符号,结构编译的时候没问题,运行时用 dlopen 打开共享库报上述错误 ...
- linux c/c++ 代码使用 doxygen 自动生成文档
www.doxygen.org 的使用非常方便,下面分成2步介绍一下 1. 注释风格,需要在c/c++代码中按照下面的风格添加注释,基本上还是很顺手的 C++的注释风格 主要使用下面这种样式:即在注释 ...
- Kubernetes-服务发布
#发布服务有三种方式,第一种把端口映射到所有节点比较适合发布一些tcp/udp的服务对于应用层像http的会导致无法获取到原始客户端IP,第二种需要用到云服务才行,第三种是ingress http服务 ...
- 初学springMVC的拦截器
springMvc拦截器的执行顺序! 拦截器的各个方法的作用: /** * 登录验证拦截器 */ public class Intercepter implements HandlerInt ...
- 【linux高级程序设计】(第九章)进程间通信-管道 3
有名管道 无名管道和有名管道: 1. 管道是特殊类型的文件,在满足先入先出的原则写可以读写,不能定位读写位置. 2.管道是单向的. 3.无名管道阻塞于读写位置,而有名管道阻塞在创建位置. 4.无名管道 ...
- CentOS6.5升级autoconf版本,解决”Autoconf version 2.64 or higher is required“错误
CentOS6.5升级autoconf版本,解决”Autoconf version 2.64 or higher is required“错误 https://blog.csdn.net/pretty ...
- HDU 6271 Master of Connected Component(2017 CCPC 杭州 H题,树分块 + 并查集的撤销)
题目链接 2017 CCPC Hangzhou Problem H 思路:对树进行分块.把第一棵树分成$\sqrt{n}$块,第二棵树也分成$\sqrt{n}$块. 分块的时候满足每个块是一个 ...
- maven的知识图谱
maven 1.maven的好处 java项目管理工具 依赖管理 对jar包统一管理 项目名称 公司/组织 版本信息 本地仓库 由于索引的存在,找jar包很快 项目构建 依赖管理 传统项目 很大 包含 ...
- Java 继承问题 -- 子类是否继承父类的私有属性
理解一: 子类会继承父类的所有属性和方法,至于能不能直接访问,那就是访问权限的问题了. 例如:父类有个private String name; 属性.子类会继承下来,但子类访问不了,因为是privat ...