🏠 ホーム 🔧 自作ツール 📓 日常のブログ 🍜 飯のブログ 📚 勉強のブログ 🗂️ その他のブログ
👃 TTManager32's Code - NoseScape

てんともち / TTManager32 Public

Application.hsp 6,502 Bytes
//ビルド設定エリア
#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.1 Stable"
AppVerInt = "1.1"
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
}

//エラーハンドリング
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 IsThisTimeCorrect int p1, int p2
		sdim tmp
		NowTime=time2ut(gettime(0),gettime(1),gettime(3),gettime(4),gettime(5),00)

		if RawList@(p1)=""       : return 0
		split RawList@(p1),"@",tmp
		if 0=instr(tmp(1),0,"*") : return 0
		if tmp(0)= NowTime+p2 {
			return 1
		}else{
			return 0
		}
	return 255

	#deffunc DoTimeCheck int p1, int p2, str p3
		repeat length(RawList@)
			if IgnoreList@(cnt,p2)!=1{
				if IsThisTimeCorrect(cnt,p1) {
					IgnoreList@(cnt,p2)=1
					sdim tmp
					sdim tmp1
					tmp=RawList@(cnt)
					split tmp,"@",tmp
					split tmp(1),"|",tmp1
					sdim out
					if length(tmp1)=2{//Todoタイプ
						strrep tmp1(1),"<br>","\n"
						out ="タスク「"+tmp1(0)+"」の\n締め切り時間"+p3+"です!"
						out+="\n留意点:\n"+tmp1(1)+""
					}else{
						out ="講義「"+tmp1(0)+"」の\n開始時間"+p3+"です!"
						out+="\n場所は "+tmp1(1)+" 、"
						out+="\nもち物:\n"+tmp1(2)+"。"
					}
					dialog out
				}
			}
		loop
	return 0
#global

*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+" - 稼働中"
	}

	DoTimeCheck    0,0,"ちょうど"
	DoTimeCheck   60,1,"の1分前"
	DoTimeCheck  600,2,"の10分前"
	DoTimeCheck 1800,3,"の30分前"
	DoTimeCheck 3600,4,"の1時間前"
	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