admin
2025-07-17 6cd92a169cbc0db35042f243a09d976fd3e1445c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "BlinkingMessageDialog.h"
#define MSG_WINDOW_SIZE wxSize(200,80)
 
BlinkingMessageDialog::BlinkingMessageDialog(wxWindow* parent, const wxString& message) : wxFrame(parent, wxID_ANY, "¿ÉתծÌáʾ", wxDefaultPosition, MSG_WINDOW_SIZE, wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxMINIMIZE_BOX))
{
    long style = GetWindowStyle();//& ~(wxCAPTION);
    style |= wxSTAY_ON_TOP;
    SetWindowStyle(style);
 
    SetBackgroundColour(*wxWHITE);
 
    m_shakeCount = 0;
 
    wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    wxStaticText* text = new wxStaticText(this, wxID_ANY, message);
    text->SetForegroundColour(*wxRED);
    sizer->Add(text, 0, wxALL | wxALIGN_CENTER);
    SetSizer(sizer);
 
    // Start blinking
    m_timer = new wxTimer(this, wxID_ANY);
    Bind(wxEVT_TIMER, &BlinkingMessageDialog::OnTimer, this);
    m_timer->Start(100);
    //»ñÈ¡ÆÁÄ»ÓÒϽÇ
    int screenWidth = GetSystemMetrics(SM_CXSCREEN);
    int screenHeight = GetSystemMetrics(SM_CYSCREEN);
    // ÓÒϽÇλÖÃ
    wxPoint bottomRight(screenWidth - MSG_WINDOW_SIZE.GetWidth()-10, screenHeight - MSG_WINDOW_SIZE.GetHeight()-10);
    SetPosition(bottomRight);
}
 
void BlinkingMessageDialog::show()
{
 
    if (!IsShown()) {
        m_timer->Stop();
        m_shakeCount = 0;
        m_timer->Start(100);
        Show();
    }
}
 
void BlinkingMessageDialog::OnTimer(wxTimerEvent& event)
{
    if (m_shakeCount < 100) {  // Shake for 6 cycles
        int dx = (m_shakeCount % 2 == 0) ? 10 : -10;
        int dy = (m_shakeCount % 2 == 0) ? 10 : -10;
        Move(GetPosition() + wxPoint(dx, dy));
        m_shakeCount++;
    }
    else {
        m_timer->Stop();
        Close();
    }
}