PDA

View Full Version : سوال: ظاهر کردن برنامه هنگامی که در کنار ساعت قرار دارد مانند تلگرام



h-avatar
یک شنبه 17 بهمن 1395, 00:14 صبح
سلام دوستان من میخوام وقتی برنامه در کنار ساعت قرار داره و من روی آیکون دکستاپ برنامه کلیک میکنم نمایش داده بشه.
من با متود visible برنامه رو مخفی و در کنار ساعت قرار میدم ولی این برنامه فقط در صورت کلیک روی notifyicon نمایش داده میشه و با کلیک روی ایکون دکستاپ اتفاقی نمی افته تمام رویداد ها رو هم تست کردم کلی هم تو سایت ها خارجی و داخلی سرچ کردم ولی به نتیجه ای نرسیدم کسی هست بتونه به من کمک کنه؟ (حتی برنامه های دیگه هم مثل idm و everything و eset هم اینجورین).

isaac23
یک شنبه 17 بهمن 1395, 08:11 صبح
ببین دوست عزیز برنامه های مثل نود 32 و دانلود منیجر خاصیتشون اینکه که همیشه آماده بکار باشن واسههمین آیکن رو در تکس بار گذاشتن تا دسترسی بهتری داشته باشه شما گه می خواهید برنامه همیشه حالت آماده بکار داشته باشه باید اونو توی استارتاپ ویندوز یا در رجستری ذخیره کنید تا به محض روشن شدن سیستم بیا و اونجا قرار بگیره و خاصیت مخفی رو داشته باشه و وقتی کنار ساعت روی آیکنش کلیک شد برنامه باز بشه .؟

یه نمونه کد برای قرار دان ایکون در Taskbar و وقتی روش کلید شد نشون بده .


اگه بدردت خورد یه صلواتی بفرست .

h-avatar
یک شنبه 17 بهمن 1395, 10:53 صبح
ممنون ولی اتفاقا داخل برنامه هم یه چک باکس هم گذاشتم که وقتی تیکش بخوره یه شورت کات داخل پوشه استارت اپ ویندوز میسازه و هنگام روشن شدن سیستم هم برنامه میره و در قسمت سیستم تری قرار میگیره اگه تیکش برداشته بشه حذف میشه ولی مشکل من چیزه دیگه ای.
مسئله من اینه که فرض کنیم برنامه در سیستم تری در حال اجرا قرار داره و کاربر یادش رفته که برنامه تو سیستم تری در حال اجراست و میره و روی آیکون دکستاپش کلیک میکنه و انتظار داره برنامه باز بشه ولی هیچ اتفاقی نمی افته و فکر میکنه برنامه دچار مشکل شده و باگ داره من میخوام برنامه از حالت مخفی در بیاد و نمایش داده بشه (الان وقتی کلیک میکنم هیچ اتفاقی نمی افته) و نمیدونم با چه حرکتی این کار رو بکنم . شما یه بار این حرکتی که میگم رو با idm انجام بده متوجه منظورم میشی.
برنامه ای هم که تحویل دادید برای من فرمتش ناشناخته است و نمیتونم بازش کنم.
یه لینک هم قرار می دم که قسمت سومش جواب راه حل من هست ولی با سی شارپ کار میکنه و نمیتونم کدهاش رو درست و حسابی بفهمم
https://www.codeproject.com/articles/32908/c-single-instance-app-with-the-ability-to-restore

gilsoft
دوشنبه 18 بهمن 1395, 00:22 صبح
سلام دوست عزیز

از قطعه کد زیر میتونی ایده بگیری ...
Imports System.Deployment.Application
Imports System.Runtime.InteropServices
Imports System.Reflection
Imports System.Threading


Friend Class Main
Inherits System.Windows.Forms.Form


Protected Overrides Sub WndProc(ByRef Message As Message)
If Message.Msg = SingleInstance.WM_SHOWFIRSTINSTANCE Then
ShowWindow()
Else
'MessageBox.Show("Application already run !")
End If
MyBase.WndProc(Message)
End Sub


Private Sub ShowWindow()
Me.WindowState = FormWindowState.Normal
Me.Focus()
End Sub


Private Sub cmdUpdate_Click(Sender As Object, e As EventArgs) Handles cmdUpdate.Click
If ApplicationDeployment.IsNetworkDeployed Then
If ApplicationDeployment.CurrentDeployment.CheckForUp date(False) Then
ApplicationDeployment.CurrentDeployment.Update()


MsgBox("The application has been updated and will now restart.", MsgBoxStyle.Information)


My.Settings.IsRestarting = True
My.Settings.Save()


Application.Restart()
End If
End If
End Sub


Friend WithEvents cmdUpdate As System.Windows.Forms.Button


Private Sub InitializeComponent()
Me.cmdUpdate = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'cmdUpdate
'
Me.cmdUpdate.Location = New System.Drawing.Point(132, 175)
Me.cmdUpdate.Name = "cmdUpdate"
Me.cmdUpdate.Size = New System.Drawing.Size(75, 23)
Me.cmdUpdate.TabIndex = 0
Me.cmdUpdate.Text = "Button1"
Me.cmdUpdate.UseVisualStyleBackColor = True
'
'Main
'
Me.ClientSize = New System.Drawing.Size(284, 262)
Me.Controls.Add(Me.cmdUpdate)
Me.Name = "Main"
Me.ResumeLayout(False)


End Sub


End Class


Namespace My
' The following events are availble for MyApplication:
'
' Startup: Raised when the application starts, before the startup form is created.
' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an unhandled exception.
' StartupNextInstance: Raised when launching a single-instance application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
Partial Friend Class MyApplication
Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup
If My.Settings.IsRestarting Then
My.Settings.IsRestarting = False
My.Settings.Save()
Thread.Sleep(3000)
End If


If Not SingleInstance.Start() Then
SingleInstance.ShowFirstInstance()
e.Cancel = True
End If
End Sub


Private Sub MyApplication_Shutdown(sender As Object, e As EventArgs) Handles Me.Shutdown
SingleInstance.Stop()
End Sub
End Class
End Namespace


Public NotInheritable Class SingleInstance
Public Shared ReadOnly WM_SHOWFIRSTINSTANCE As Integer = WinApi.RegisterWindowMessage("WM_SHOWFIRSTINSTANCE|{0}", ProgramInfo.AssemblyGuid)
Private Shared Mutex As Mutex


Public Shared Function Start() As Boolean
Dim lIsOnlyInstance As Boolean
Dim sMutexName As String


lIsOnlyInstance = False
sMutexName = String.Format("Local\{0}", ProgramInfo.AssemblyGuid)


' If you want your app to be limited to a single instance
' across ALL SESSIONS (multiple users & terminal services),
' then use the following line instead:
' sMutexName = String.Format("Global\\{0}", ProgramInfo.AssemblyGuid);


Mutex = New Mutex(True, sMutexName, lIsOnlyInstance)
Return lIsOnlyInstance
End Function


Public Shared Sub ShowFirstInstance()
WinApi.PostMessage(New IntPtr(WinApi.HWND_BROADCAST), WM_SHOWFIRSTINSTANCE, IntPtr.Zero, IntPtr.Zero)
End Sub


Public Shared Sub [Stop]()
Mutex.Close()
End Sub
End Class


Public NotInheritable Class WinApi
<DllImport("user32")> _
Public Shared Function RegisterWindowMessage(message As String) As Integer
End Function


<DllImport("user32")> _
Public Shared Function PostMessage(hwnd As IntPtr, msg As Integer, wparam As IntPtr, lparam As IntPtr) As Boolean
End Function


<DllImport("user32")> _
Public Shared Function ShowWindow(hWnd As IntPtr, nCmdShow As Integer) As Boolean
End Function


<DllImport("user32")> _
Public Shared Function SetForegroundWindow(hWnd As IntPtr) As Boolean
End Function


Public Shared Function RegisterWindowMessage(Template As String, ParamArray Values As Object()) As Integer
Return RegisterWindowMessage(String.Format(Template, Values))
End Function


Public Shared Sub ShowToFront(Window As IntPtr)
ShowWindow(Window, SW_SHOWNORMAL)
SetForegroundWindow(Window)
End Sub


Public Const HWND_BROADCAST As Integer = &HFFFF
Public Const SW_SHOWNORMAL As Integer = 1
End Class


Public NotInheritable Class ProgramInfo
Public Shared ReadOnly Property AssemblyGuid As String
Get
Dim aAttributes As Object()


aAttributes = Assembly.GetEntryAssembly.GetCustomAttributes(GetT ype(GuidAttribute), False)


If aAttributes.Length = 0 Then
AssemblyGuid = String.Empty
Else
AssemblyGuid = DirectCast(aAttributes(0), GuidAttribute).Value
End If
End Get
End Property
End Class
موفق باشید .....