PDA

View Full Version : سوال: باز کردن عکس ها از مسیر برنامه در گالری عکس ویژوال بیسیک



saeed7474
جمعه 29 شهریور 1392, 13:53 عصر
سلام

من یه گالری عکس درست کردم و یه عکس کوچیک بعنوان پیش نمایش گذاشتم میخوام رو عکس کلیک بشه با نمایشگر عکس خود ویندوز نمایش بده
Shell "explorer.exe app.path & \Pic\gallery\1\1.jpg"

این کدو میزنم کار نمی کنه

چیکار باید بکنم لطفا راهنمایی کنید
باتشکر

saeed7474
شنبه 30 شهریور 1392, 00:32 صبح
کسی نمی دونه ؟

amin32
شنبه 30 شهریور 1392, 01:56 صبح
به این شکل عمل کنید :


Shell "explorer.exe " & app.path & "\Pic\gallery\1\1.jpg"

policweb
شنبه 30 شهریور 1392, 03:20 صبح
سلام یه نکته دیگه دستور شل یه خصیصه دیگه که داره اینه میشه پنجره image viwe شما رو max-min-normalکنه و اینکار رو با اعداد 0تا5میتونید انجام بدید
مثال
Shell "explorer.exe " & app.path & "\Pic\gallery\1\1.jpg",0
این پنجرتون رو پنهان میکنه و اگه 1 بزارید تمام صفحه میشه

saeed7474
شنبه 30 شهریور 1392, 13:04 عصر
مرسی دوستان درست شد

saeed7474
سه شنبه 09 مهر 1392, 13:31 عصر
متاسفانه این کد یه مشکل داره !

وقتی تو محیط ویزوال بیسیک می نویسم درسته عکس باز میشه
اما وقتی خروجی میکنم و فایل ستاپشو نصب میکنم رو ویندوز عکسو باز نمیکنه ! فقط پوشه مای داکیومنت رو باز میکنه !
مشکلش کجاست
مسیر هم درسته
app.path

saeed7474
سه شنبه 09 مهر 1392, 19:54 عصر
دوستان لطفا اگه مشکل رو میدونید راهنمایی کنید

محسن واژدی
چهارشنبه 10 مهر 1392, 01:19 صبح
سلام علیکم
از ShellExecute استفاده کنید:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", App.Path & "\Pic\gallery\1\1.jpg", vbNullString, vbNullString, vbNormalFocus
End Sub

موفق باشید

saeed7474
چهارشنبه 10 مهر 1392, 13:38 عصر
دوست عزیز کد شما تو خود برنامه کار میکنه درست اما وقتی نصب میکنم رو ویندوز نه اصلا هیچ عملی نمی کنه ! این کد رو تو general فرم مینویسم
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
و اینو تو image-click

ShellExecute Me.hwnd, "open", App.Path & "\Pic\gallery\1\1.jpg", vbNullString, vbNullString, vbNormalFocus

محسن واژدی
پنج شنبه 11 مهر 1392, 04:43 صبح
دوست عزیز کد شما تو خود برنامه کار میکنه درست اما وقتی نصب میکنم رو ویندوز نه اصلا هیچ عملی نمی کنه ! این کد رو تو general فرم مینویسم
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
و اینو تو image-click

ShellExecute Me.hwnd, "open", App.Path & "\Pic\gallery\1\1.jpg", vbNullString, vbNullString, vbNormalFocus

کد مشکلی نداشت، چک کنید که پوشه Pic\Gallery\1 در مسیر برنامه کامپایل شده وجود داشته باشه، اگر همچنان مشکل پابرجا بود نمونه سورس از مشکل هم ضمیمه تاپیک کنید

برای بررسی دقیق تر تابع زیر را بررسی کنید (در صورت بروز خطا پیام متناظر ظاهر میشه)
Public Sub Run(sPath$)
Dim iSERet%
iSERet% = ShellExecute(Me.hwnd, "open", sPath$, vbNullString, App.Path, vbNormalFocus)

Select Case iSERet:
Case 0: MsgBox "The operating system is out of memory or resources.", vbCritical
Case 2: MsgBox "The specified file was not found", vbCritical
Case 3: MsgBox "The specified path was not found.", vbCritical
Case 5: MsgBox "Windows 95 only: The operating system denied access to the specified file complete the operation.", vbCritical
Case 10: MsgBox "Wrong Windows version", vbCritical
Case 11: MsgBox "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).", vbCritical
Case 12: MsgBox "Application was designed for a different operating system", vbCritical
Case 13: MsgBox "Application was designed for MS-DOS 4.0", vbCritical
Case 15: MsgBox "Attempt to load a real-mode program", vbCritical
Case 16: MsgBox "Attempt to load a second instance of an application with non-readonly data segments", vbCritical
Case 19: MsgBox "Attempt to load a compressed application file", vbCritical
Case 20: MsgBox "Dynamic-link library (DLL) file failure", vbCritical
Case 26: MsgBox "A sharing violation occurred.", vbCritical
Case 27: MsgBox "The filename association is incomplete or invalid. because the request timed out.", vbCritical
Case 29: MsgBox "The DDE transaction failed.", vbCritical
Case 30: MsgBox "The DDE transaction could not be completed because other DDE transactions were being processed.", vbCritical
Case 31: MsgBox "There is no application associated with the given filename extension.", vbCritical
Case 32: MsgBox "Windows 95 only: The specified dynamic-link library was not found.", vbCritical
End Select

End Sub

برای مثال:

Private Sub Image1_Click()
Call Run(App.Path & "\Pic\gallery\1\1.jpg")
End Sub

موفق باشید