//ビルド設定エリア
#packopt version "Build.ini" //詳細
#packopt icon "image.ico" //アイコン
#packopt hide 1
#define ctype HIWORD(%1) (%1 >> 16 & $FFFF)
//===================================================================================
//ライブラリのロード
#include "libs/modTaskDialog/modTaskDialog.as"
//UTF-8化
#include "hsp3utf.as"
//更新確認用
#include "hspinet.as"
//定数
AppName = "Time&Task Manager 32"
AppVer = "1.4 Stable"
AppVerInt = "1.4"
DeadLine = 2038
//2038年問題の対応
//2038年以降
if gettime(0)>DeadLine-1 {
tmp =""+AppName+"をご利用いただき、ありがとうございました。\n\n"
tmp+="本ソフトウェアは32ビットであり、2038年問題の影響を受けます。\n"
tmp+="よって、2038年1月19日ごろからオーバーフローが発生します。\n\n"
tmp+="整合性を守るため、本ソフトウェアは今後利用できません。\n"
tmp+="OKを押すと、安全に終了できます。"
dialog tmp,1,AppName
end
}
//2037年
if gettime(0)=DeadLine-1 {
tmp =""+AppName+"をご利用いただき、ありがとうございます。\n\n"
tmp+="本ソフトウェアは32ビットであり、2038年問題の影響を受けます。\n"
tmp+="よって、2038年1月19日ごろからオーバーフローが発生します。\n\n"
tmp+="整合性を守るため、2038年から、本ソフトウェアは起動しなくなります。\n"
tmp+="今年度中に、他の環境へ移行してください。"
dialog tmp,1,AppName
}
#module
#uselib "kernel32.dll"
#func CloseHandle "CloseHandle" int
#cfunc CreateMutex "CreateMutexA" int, int, sptr
#cfunc GetLastError "GetLastError"
#define ERROR_ALREADY_EXISTS 183
#define MUTEX_NAME AppName@
#defcfunc AlreadyAppRunning
if (hMutex == 0) {
hMutex = CreateMutex(0, 0, MUTEX_NAME)
if (GetLastError() == ERROR_ALREADY_EXISTS) {
alreadyRunning = 1
} else {
alreadyRunning = 0
}
}
return alreadyRunning
#deffunc CleanupAppRunChecker onexit
if (hMutex != 0) {
CloseHandle hMutex
hMutex = 0
}
return
#global
if (AlreadyAppRunning()) { dialog "すでに起動されているようです。\nタスクトレイを確認ください。" : end }
//エラーハンドリング
onerror *onerror_handle
//終了時の処理の予約
onexit *exit
//システム設定のロード
#include "SettingLoader.hsp"
font Var_FontName//フォント指定
//////////////////////////////////////////////////////////////////
//アプリエリア
//タスクトレイ依存関係
#include "kernel32.as"
#include "shell32.as"
#include "user32.as"
//DPI対策
#uselib "kernel32" //Kernel32.dllを利用する
#uselib "user32.dll" //user32.dllを利用する
#func SetProcessDpiAwarenessContext "SetProcessDpiAwarenessContext" int //DPI関数(上位)の定義
#func SetProcessDPIAware "SetProcessDPIAware" //DPI関数(下位)の定義
//モード別DPI対応
switch Var_DPIMode
case 1 : SetProcessDpiAware : swbreak
case 2 : SetProcessDpiAwarenessContext -4 : swbreak
default : swbreak
swend
#module
#defcfunc TrueScale int p1
return 1.0*Var_ViewScale@*p1
#global
//GUI設定
screen 0,TrueScale(1000),TrueScale(600),0 //画面サイズを設定
width ,,ginfo(20)/2-TrueScale(500),ginfo(21)/2-TrueScale(300) //デスクトップの中心に表示
title AppName+" v"+AppVer+" - 初期化中"
color 192,192,192:boxf:color 0,0,0 //色の初期化
//全面表示設定
if Var_isForceTop {
gsel 0,2
}else{
gsel 0,1
}
//アイコン生成
RegisterWindowMessage "TaskbarCreated"
oncmd gosub *OnTaskbarCreated, stat // "TaskbarCreated"
oncmd gosub *OnDestroy, 0x0002 // WM_DESTROY
oncmd gosub *OnTrayIcon, 0x0401 // WM_TRAYICON
oncmd gosub *OnSize, $0005
title "GUIパネルを表示する"
gosub *AddTaskbarIcon
title AppName+" v"+AppVer+" - 初期化中"
redraw 0
//時間割タイルの生成
#include "button_tiles.hsp"
//Todoリストの生成
#include "todo_list.hsp"
//タイムライン
#include "next_list.hsp"
//残りのボタン類
#include "some_buttons.hsp"
redraw 1
/////////////////////////////////////////////////////
//設定のロード
gosub *Config_load
/////////////////////////////////////////////////////
//イベント登録
oncmd gosub *OnClicked, $111
//設定によっては自動最小化
if Var_AutoMinimize {
sendmsg hwnd, $112, $F020
}
//把握関数
#module
#defcfunc Time_str int p1
sdim tmp
if p1<1{return "ちょうど"}//0以下
dim Day
dim Hour
dim Min
dim sec
Min =(p1/60)\60
Hour =((p1/60)/60)\60
if Hour = 0{return "まで "+str(Min)+"分"}
Day =(((p1/60)/60)/60)\60
if Day = 0{return "まで "+str(Hour)+"時間 "+str(Min)+"分"}
return "まで "+str(Day)+"日 "+str(Hour)+"時間 "+str(Min)+"分"
#defcfunc IsThisTimeCorrectK int p1, int p2
sdim tmp
NowTime=time2ut(gettime(0),gettime(1),gettime(3),gettime(4),gettime(5),00)
if TodayList@(p1)="" : return 0
split TodayList@(p1),"@",tmp
if 0=instr(tmp(1),0,"*") : return 0
if tmp(0)= NowTime+p2 {
return 1
}else{
return 0
}
return 255
#defcfunc IsThisTimeCorrectT int p1, int p2
sdim tmp
NowTime=time2ut(gettime(0),gettime(1),gettime(3),gettime(4),gettime(5),00)
if tasklist@(p1)="" : return 0
split tasklist@(p1),"@",tmp
if 0=instr(tmp(1),0,"*") : return 0
if tmp(0)= NowTime+p2 {
return 1
}else{
return 0
}
return 255
#deffunc DoKomaTimeCheck int p1, int p2
repeat length(TodayList@)
if IgnoreListK@(cnt,p2)!=1{
if IsThisTimeCorrectK(cnt,p1) {
IgnoreListK@(cnt,p2)=1
sdim tmp
sdim tmp1
tmp=TodayList@(cnt)
split tmp,"@",tmp
split tmp(1),"|",tmp1
sdim out
out ="講義「"+tmp1(0)+"」の\n開始"+Time_str(p1)+"です!"
out+="\n場所は "+tmp1(1)+" 、"
out+="\nもち物:\n"+tmp1(2)+"。"
dialog out
}
}
loop
return 0
#deffunc DoTaskTimeCheck int p1, int p2
repeat length(tasklist@)
// dialog cnt
if IgnoreListT@(cnt,p2)!=1{
if IsThisTimeCorrectT(cnt,p1) {
IgnoreListT@(cnt,p2)=1
sdim tmp
sdim tmp1
tmp=tasklist@(cnt)
split tmp,"@",tmp
split tmp(1),"|",tmp1
sdim out
strrep tmp1(1),"<br>","\n"
out ="タスク「"+tmp1(0)+"」の\n締め切り時間"+Time_str(p1)+"です!"
out+="\n留意点:\n"+tmp1(1)+""
dialog out
}
}
loop
return 0
#global
if Var_IsEnableUpdate {
isFirst=1
// gosub *UpdateCheck
}
*main
if gettime(7)/100 >=7.5 {
title AppName+" v"+AppVer+" - 稼働中."
}else : if gettime(7)/100 >=4 {
title AppName+" v"+AppVer+" - 稼働中.."
}else : if gettime(7)/100 >=2 {
title AppName+" v"+AppVer+" - 稼働中."
}else{
title AppName+" v"+AppVer+" - 稼働中"
}
repeat length(Var_AlertKomaTime)
DoKomaTimeCheck int(Var_AlertKomaTime(cnt)),cnt
loop
repeat length(Var_AlertTodoTask)
DoTaskTimeCheck int(Var_AlertTodoTask(cnt)),cnt
loop
await 10
goto *main
/////////////////////////////////////////////////////
//スタティックエリア
#include "UpdateManager.hsp"
#include "config_loader.hsp"
#include "event_button_manager.hsp"
#include "event_click_manager.hsp"
#include "functionManager.hsp"
*onerror_handle
tmp ="重大な問題が発生しました。\n"+AppName+"のGUIパネルを終了します。\n\n"
tmp+="バージョン:"+AppVer+"\n"
tmp+="エラーコード: "
tmp+="0x"+strf("%04d",wparam)
tmp+="\n\n上記のデバッグ情報と状況を報告してくださると、修正の助けになります!"
dialog tmp,1
end
*AddTaskbarIcon
sdim FileName, 65535
GetModuleFileName hModule, varptr(FileName), 65535
ExtractIconEx varptr(FileName), 0, 0, varptr(hIconSmall), 1
hIcon = hIconSmall(0)
GetWindowTextLength hwnd
sdim WindowTitle, stat + 1
GetWindowText hwnd, varptr(WindowTitle), stat + 1
dim IconData,22
IconData(0) = 88
IconData(1) = hwnd
IconData(2) = 1
IconData(3) = 0x0007 // NIF_MESSAGE | NIF_ICON | NIF_TIP
IconData(4) = 0x0401 // WM_TRAYICON
IconData(5) = hIcon
poke IconData, 4 * 6, WindowTitle
Shell_NotifyIcon 0x00000000, varptr(IconData) // NIM_ADD
return
*OnTaskbarCreated
gosub *AddTaskbarIcon
return
*OnDestroy
goto *exit
return
*OnTrayIcon
if (wparam == 1) {
switch (lparam)
case 0x0201 // WM_LBUTTONDOWN
ShowWindow hwnd,4
swbreak
swend
}
return
*OnSize
if wparam=1 { gsel 0,-1 }
return
*exit
dim IconData,22
IconData(0) = 88
IconData(1) = hwnd
IconData(2) = 1
IconData(3) = 0x0002 // NIF_ICON
Shell_NotifyIcon 0x00000002, varptr(IconData) // NIM_DELETE
end