2 שאלות

SpecialNight

New member
2 שאלות

1. יצרתי מחשבון פשוט עם window forms ב visual studio.net,הבעיה היא שכשאני מפעיל את האפליקציה אז החלון של ה Dos לא נסגר,איך סוגרים אותו כאשר פותחים את קובץ ה exe? 2. איך אני עושה alert?
 

gilad g

New member
המממ

1. חלון Dos? לא אמרת שזו אפליקציית Windows Forms? 2. התכוונת ל-alert כמו שיש ב-Javascript?
אתה קורא ל-MessageBox.Show.
 

SpecialNight

New member
המממ

אני מתכוון לזה... יש מאחורה חלוס דוס וזה מעצבן אותי.
 

gilad g

New member
זה בגלל

שאתה מקמפל את הפרוייקט כ-exe ולא כ-winexe
 

SpecialNight

New member
יש לי עוד שאלה

יש לי את הקוד הזה:
using System; using System.Drawing; using System.Windows.Forms; public class GDISample : Form { override protected void OnPaint(PaintEventArgs pe) { Brush brush=new SolidBrush(Color.Black); pe.Graphics.FillEllipse(brush,0,0,this.ClientSize.Width,this.ClientSize.Height); } [STAThread] public static void Main() { Application.Run(new GDISample()); } }​
וזה עובד! אבל אני לא מבין מאיפה בדיוק אנחנו קוראים לפונקציה: OnPaint ואיפה בדיוק אנחנו שולחים אליה את הפרמטר pe.
 

Zeliran

New member
../images/Emo26.gif

OnPaint היא כנראה Event, מה שאומר שהתוכנית קוראת לה בכל פעם שארוע מסויים (שאליו היא מקושרת) קורה ואז התוכנית הולכת אל הפונקציה OnPaint ככה שאתה לא צריך לכתוב הפניה בקוד עצמו שקוראת לפונקציה..
 

gilad g

New member
תיקון קליל

OnPaint היא לא event... אלא מתודה שה-base class (במקרה הזה, Form) קורא לה.
 

SpecialNight

New member
ומה קורה אם אני רוצה להמיר ל asp+?

הרי אני כבר לא משתמש יותר ב windows forms,אז איזו מתודה ב aspx יכולה לקרוא ל OnPaint? מאיזו מתודה אני יכול לרשת? ובאיזה namespace היא נמצאת? תודה.
 

gilad g

New member
ב-asp.net התהליך הוא שונה לגמרי

אתה צריך ליצור IHttpHandler שמייצר תמונה באופן דינאמי (Content Type שונה), ובעמוד HTML שלך אתה שם תגית img עם ההפניה ל-IHttphandler שיצרת. כדי ליצור את התמונה, אתה יוצר אובייקט מסוג Bitmap, משיג את ה-Graphics שלו, ועל זה עושה את הציור של מה שאתה צריך לצייר (גרף?).
 

SpecialNight

New member
הממממ

תודה על התשובה המפורטת :) אבל אני עדיין לא מבין מה התפקיד של IHttpHandler בכל ה .Net... מצד אחד אומרים לי שזה פתרון נהדר לבעיות אבטחה ומצד שני אומרים לי שאני יכול לייצר עם זה תמונות... ואיך אני קורא מהתמונה ל IHttpHandler? יש לך מאמר טוב על IHttpHandler בהקשר לבעיה שלי? תודה.
 

gilad g

New member
המממ

הנה משהו שמצאתי ב-MSDN, בעזרת חיפוש פשוט בגוגל, אני מניח שאם גם אתה תחפש, אתה תמצא. הדוגמא מדברת על הקטנת תמונות, אבל זה על אותו עיקרון
 

SpecialNight

New member
../images/Emo53.gif

ביצעתי את כל מה שצריך שם ואפילו מספר פעמים. וקיבלתי שגיאה מעצבנת...קובץ ה HTML מצורף. אודה לך מאוד אם תוכל לעזור לי... בכל מקרה הנה ה source:
Web Config <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <!-- DYNAMIC DEBUG COMPILATION Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to false will improve runtime performance of this application. Set compilation debug="true" to insert debugging symbols (.pdb information) into the compiled page. Because this creates a larger file that executes more slowly, you should set this value to true only when debugging and to false at all other times. For more information, refer to the documentation about debugging ASP .NET files. --> <compilation defaultLanguage="c#" debug="true" /> <!-- CUSTOM ERROR MESSAGES Set customError mode values to control the display of user-friendly error messages to users instead of error details (including a stack trace): "On" Always display custom (friendly) messages "Off" Always display detailed ASP.NET error information. "RemoteOnly" Display custom (friendly) messages only to users not running on the local Web server. This setting is recommended for security purposes, so that you do not display application detail information to remote clients. --> <customErrors mode="RemoteOnly" /> <!-- AUTHENTICATION This section sets the authentication policies of the application. Possible modes are "Windows", "Forms", "Passport" and "None" --> <authentication mode="Windows" /> <!-- APPLICATION-LEVEL TRACE LOGGING Application-level tracing enables trace log output for every page within an application. Set trace enabled="true" to enable application trace logging. If pageOutput="true", the trace information will be displayed at the bottom of each page. Otherwise, you can view the application trace log by browsing the "trace.axd" page from your web application root. --> <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" /> <!-- SESSION STATE SETTINGS By default ASP .NET uses cookies to identify which requests belong to a particular session. If cookies are not available, a session can be tracked by adding a session identifier to the URL. To disable cookies, set sessionState cookieless="true". --> <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user id=sa;password=" cookieless="false" timeout="20" /> <!-- GLOBALIZATION This section sets the globalization settings of the application. --> <globalization requestEncoding="utf-8" responseEncoding="utf-8" /> <httpHandlers> <add verb="*" path="*.hello" type="FirstHttpHandler.HelloWorld, FirstHttpHandler" /> </httpHandlers> </system.web> </configuration> HelloWorld.cs using System; using System.Web; namespace FirstHttpHandler { public class HelloWorld : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { HttpRequest Request = context.Request; HttpResponse Response = context.Response; HttpServerUtility Server = context.Server; &nbs​
 

SpecialNight

New member
והפתרון

ב visual studio.net יש ללחוץ ctrl + shift + b ואז הוא מציג לך תבעיה ואז סימנתי בהערות 2 שורות שלא הבאתי להם רפרנס כי לא עשיתי using ל namespace שלהם אבל זה הכל בעקרון.
 
למעלה