Search Results

Search found 2441 results on 98 pages for 'delegate'.

Page 45/98 | < Previous Page | 41 42 43 44 45 46 47 48 49 50 51 52  | Next Page >

  • Calling managed code from unmanaged win32 assembly dll - crash

    - by JustGreg
    I'm developing a serial port dll in win32 assembly (MASM32). It has its own thread checking multiple events and at a specified buffer treshold it'd notify the managed main application by calling a callback function. It just a call with no arguments/return value. At startup the main application stores the callback function's address by calling a function in the dll: pCallBackFunction dd 0 SetCallBackPointer proc pcb:DWORD mov eax, pcb mov pCallBackFunction, eax call DWORD ptr pCallBackFunction ; verify it immediately ret SetCallBackPointer endp The upper function immediately calls back the managed application callback routine for verification purposes. It is working fine. However, when I place the call instruction to other functions in the dll it crashes the application. It doesn't matter if the call is in a simple function or in the threadproc of the dll. For example: OpenPort proc pn:byte,br:dword, inputbuffersize: dword, outputbuffersize:dword, tresholdsize: dword LOCAL dcb: DCB LOCAL SerialTimeOuts: COMMTIMEOUTS call DWORD ptr pCallBackFunction xor eax, eax mov al, pn mov [com_port+3],al etc. etc. will crash at call DWORD ptr pCallBackFunction always. Since I call SetCallBackPointer first to store a valid address in pCallBackFunction, it should have a valid address. My managed app is written in C# and the relevant part is: public partial class Form1 : Form { public delegate void CallBackDelegate(); public static CallBackDelegate mydelegate; [DllImport("serialport.dll")] private static extern void SetCallBackPointer(CallBackDelegate Delegate); [DllImport("serialport.dll")] public static extern int OpenPort(byte com, uint br, uint inbufsize, uint outbufsize, uint treshsize); public Form1() { InitializeComponent(); mydelegate =new CallBackDelegate(CallbackFunction); SetCallBackPointer(mydelegate); unsafe { int sysstat; int hResult; hResult = OpenPort(Convert.ToByte('5'), 9600, 306, 4, 4); } } public static void CallbackFunction() { MessageBox.Show( "CallBack Function Called by Windows DLL"); } The VS debugger reported that the dll had tried to read/write from/to a protected memory address. But when calling SetCallBackPointer there is no such problem. What am I doing wrong here? Any tips would be great!

    Read the article

  • inputAccessoryView not hide the view when -resignFirstResponder?

    - by Sam Jarman
    I have attached a toolbar with a UITextField and UIButton to the keyboard when it becomes the first responder via the user taping inside the textfield textField.inputAccessoryView = theToolbar; Problem is, the toolbar disappears when the keyboard is dismissed, thus preventing any further input. Any ideas on how to make the toolbar go back to the bottom of the screen rather than off it completely? I'm thinking a delegate method might help but Im really not too sure. It seems once the inputAccessoryView always the inputAccessoryView :( Cheers

    Read the article

  • Vfr/reader when to read a page

    - by juliet
    I downloaded vfr reader soure code on github. I am reading it, I found when need show a page of PDF, it will call showdocument method in showdocument method, it will new a readercontentview in readercontentview it will new a readercontentpage which has a citiedlayer delegate method called drawlayer:incontext I don't understand when and how to call this method, because there is no update for the readercontentview.

    Read the article

  • BlockingQueue decorator that logs removed objects

    - by scompt.com
    I have a BlockingQueue that's being used in a producer-consumer situation. I would like to decorate this queue so that every object that's taken from it is logged. I know what the straightforward implementation would look like: simply implement BlockingQueue and accept a BlockingQueue in the constructor to which all of the methods would delegate. Is there another way that I'm missing? A library perhaps? Something with a callback interface?

    Read the article

  • NSTextField enter to trigger action

    - by Chris
    I've been looking all over for a simple example of how to have an action (or button) be triggered when the enter key is hit in the text field. Should I subclass the text field? Would I need to set a delegate to call the action I need? Is there a way to catch the event in my main window controller class? If you could even just point me to the right direction that would be great. Thanks.

    Read the article

  • how to enter text into uitextfield

    - by adnan
    I have implemented the delegates for UITextField and also method for these text field. Below are the methods: - (void)textFieldDidBeginEditing:(UITextField *)textField { [textField resignFirstResponder]; } - (BOOL)textFieldShouldReturn:(UITextField *)aTextField { [aTextField resignFirstResponder]; return YES; } My problem is that when I want to enter text into UITextField its delegate does not allow me to enter the text into textfields. Kindly tell me how i can enter the data into textfields

    Read the article

  • load the videos in ipod/iphone library but always crash

    - by user262325
    Hello everyone I hope to load the videos in ipod/iphone library and list in UITableView like app 'videos'. the codes show below, but it always cause crash UIImagePickerController *picker=[[UIImagePickerController alloc]init]; picker.sourceType= UIImagePickerControllerSourceTypePhotoLibrary; picker.mediaTypes = [NSArray arrayWithObject:kUTTypeMovie]; picker.delegate = self; Welcome any comment Thanks interdeb

    Read the article

  • Searching a Better Solution with Delegates

    - by spagetticode
    Hey All, I am a newbie in C# and curious about the better solution of my case. I have a method which gets the DataTable as a parameter and creates a List with MyClass's variables and returns it. public static List<Campaigns> GetCampaignsList(DataTable DataTable) { List<Campaigns> ListCampaigns = new List<Campaigns>(); foreach (DataRow row in DataTable.Rows) { Campaigns Campaign = new Campaigns(); Campaign.CampaignID = Convert.ToInt32(row["CampaignID"]); Campaign.CustomerID = Convert.ToInt32(row["CustomerID"]); Campaign.ClientID = Convert.ToInt32(row["ClientID"]); Campaign.Title = row["Title"].ToString(); Campaign.Subject = row["Subject"].ToString(); Campaign.FromName = row["FromName"].ToString(); Campaign.FromEmail = row["FromEmail"].ToString(); Campaign.ReplyEmail = row["ReplyEmail"].ToString(); Campaign.AddDate = Convert.ToDateTime(row["AddDate"]); Campaign.UniqueRecipients = Convert.ToInt32(row["UniqueRecipients"]); Campaign.ClientReportVisible = Convert.ToBoolean(row["ClientReportVisible"]); Campaign.Status = Convert.ToInt16(row["Status"]); ListCampaigns.Add(Campaign); } return ListCampaigns; } And one of my another DataTable method gets the DataTable from the database with given parameters. Here is the method. public static DataTable GetNewCampaigns() { DataTable dtCampaigns = new DataTable(); Campaigns Campaigns = new Campaigns(); dtCampaigns = Campaigns.SelectStatus(0); return dtCampaigns; } But the problem is that, this GetNewCampaigns method doesnt take parameters but other methods can take parameters. For example when I try to select a campaign with a CampaignID, I have to send CampaignID as parameter. These all Database methods do take return type as DataTable but different number of parameters. public static DataTable GetCampaignDetails(int CampaignID) { DataTable dtCampaigns = new DataTable(); Campaigns Campaigns = new Campaigns(); dtCampaigns = Campaigns.Select(CampaignID); return dtCampaigns; } At the end, I want to pass a Delegate to my first GetCampaignList Method as parameter which will decide which Database method to invoke. I dont want to pass DataTable as parameter as it is newbie programming. Could you pls help me learn some more advance features. I searched over it and got to Func< delegate but could not come up with a solution.

    Read the article

  • intialization with a nibFIle failed

    - by zp26
    Hi, I have a problem. I try to initialize a variabile in a classViewController created inside a xib file. I try with the code below but when i append a object to array, these array isn't initialized. Can you help me? thanks and sorry for my english. #import <UIKit/UIKit.h> @interface AccelerometroViewController : UIViewController <UIAccelerometerDelegate, UITextFieldDelegate, UIAlertViewDelegate>{ //..... NSMutableArray *arrayPosizioni; NSMutableArray *arrayPosizioniCorrenti; NSString *nomePosizioneCorrente; } -(IBAction)salvaPosizione; //... @property (nonatomic, assign) NSMutableArray *arrayPosizioni; @property (nonatomic, assign) NSMutableArray *arrayPosizioniCorrenti; @property (nonatomic, assign) NSString *nomePosizioneCorrente; @end #import "AccelerometroViewController.h" #import "Position.h" @implementation AccelerometroViewController float actualX; float actualY; float actualZ; @synthesize arrayPosition; @synthesize arrayCurrentPosition; @synthesize nameCurrentPosition; -(id)init { self = [super init]; if (self != nil) { arrayPosition = [[NSMutableArray alloc]init]; arrayCurrentPosition = [[NSMutableArray alloc]init]; nameCurrentPosition = [NSString stringWithFormat:@"noPosition"]; actualX = 0; actualY = 0; actualZ = 0; } return self; } -(void)updateTextView:(NSString*)nomePosizione { NSString *string = [NSString stringWithFormat:@"%@", nameCurrentPosition]; textEvent.text = [textEvent.text stringByAppendingString:@"\n"]; textEvent.text = [textEvent.text stringByAppendingString:string]; } -(IBAction)savePosition{ Posizione *newPosition; newPosition = [[Position alloc]init]; if([newPosition setValue:(NSString*)fieldNomePosizione.text:(float)actualX:(float)actualY:(float)actualZ]){ //setValue is a method of Position. I'm sure that this method is correct UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Salvataggio Posizione" message:@"Posizione salvata con successo" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; [alert show]; [alert release]; [arrayPosition addObject:newPosition]; } else{ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Salvataggio osizione" message:@"Errore nel salvataggio" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil]; [alert show]; [alert release]; } } - (void) initialise { arrayPosition = [[NSMutableArray alloc] init]; arrayCurrentPosition = [[NSMutableArray alloc] init]; nameCurrentPosition = @"noPosition"; actualX = 0; actualY = 0; actualZ = 0; } - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle { if (self = [super initWithNibName:nibName bundle:bundle]) { [self initialise]; } }

    Read the article

  • Implement delegates for Core Data or not

    - by Spanky
    What advantage is there to implementing the four delegate methods: (void)controllerWillChangeContent:(NSFetchedResultsController *)controller (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id )sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath (void)controllerDidChangeContent:(NSFetchedResultsController *)controller rather than implement: (void)controllerDidChangeContent:(NSFetchedResultsController *)controller Any help appreciated // :)

    Read the article

  • Sharing parameters between setting view and application view

    - by Tibi
    Hi there, Simple question : I've got an iPhone app with 2 views with each a separated xib files. one view holds the settings of the app one view holds the app using the settings made in previous view. How should I implement the sharing of setup parameters between the 2 views ? should I manage those parameters in the app delegate ?

    Read the article

  • Disable iOS keyboard (don't show it at all) in phonegap

    - by lashleigh
    If I were writing a native app I would try the solution given here which says: Try to implement the following method in text view's delegate: - (BOOL)textViewShouldBeginEditing:(UITextView *)textView{ return NO; } Unfortunately I need to use phonegap, so I don't have a text view to manipulate. It would be great if I could permanently suppress the keyboard in this app. We've got some custom on screen keyboard that people are supposed to use instead. So, any idea how to disable the popup keyboard completely?

    Read the article

  • Django modelform ForeignKey List

    - by Harry
    How do you get each item in the ForeignKey field in a list, for example: class Delegate(models.Model): excursion = models.ForeignKey(Excursion, limit_choices_to = {'is_activity': False}, related_name='excursion', null=True, blank=True) Template: {% for object in formset.excursion_set.all %} {{ object.lable }} etc {% endfor %} My reason is that I don't want the options to display as a dropdown, but in a custom way that I will style etc.

    Read the article

  • adding a UITableView programmatically to a UIViewController

    - by Adam
    I'm loading a UIViewController into one of my Nav controller's hierarchies, which will contain some text and some images. At the bottom, I will want to create a expandable and collapsable tableview. First off, is this idea possible? If it is, how do I add it and where do I place the data source and delegate methods? Can I just make a separate subclass of the TableViewController and then add it to my ViewController as a subview?

    Read the article

  • Translating a C# WCF app into Visual Basic

    - by MikeG
    I'm trying to write a simple/small Windows Communication Foundation service application in Visual Basic (but I am very novice in VB) and all the good examples I've found on the net are written in C#. So far I've gotten my WCF service application working but now I'm trying to add callback functionality and the program has gotten more complicated. In the C# example code I understand how everything works but I am having trouble translating into VB the portion of code that uses a delegate. Can someone please show the VB equivalent? Here is the C# code sample I'm using for reference: namespace WCFCallbacks { using System; using System.ServiceModel; [ServiceContract(CallbackContract = typeof(IMessageCallback))] public interface IMessage { [OperationContract] void AddMessage(string message); [OperationContract] bool Subscribe(); [OperationContract] bool Unsubscribe(); } interface IMessageCallback { [OperationContract(IsOneWay = true)] void OnMessageAdded(string message, DateTime timestamp); } } namespace WCFCallbacks { using System; using System.Collections.Generic; using System.ServiceModel; public class MessageService : IMessage { private static readonly List<IMessageCallback> subscribers = new List<IMessageCallback>(); //The code in this AddMessage method is what I'd like to see re-written in VB... public void AddMessage(string message) { subscribers.ForEach(delegate(IMessageCallback callback) { if (((ICommunicationObject)callback).State == CommunicationState.Opened) { callback.OnMessageAdded(message, DateTime.Now); } else { subscribers.Remove(callback); } }); } public bool Subscribe() { try { IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>(); if (!subscribers.Contains(callback)) subscribers.Add(callback); return true; } catch { return false; } } public bool Unsubscribe() { try { IMessageCallback callback = OperationContext.Current.GetCallbackChannel<IMessageCallback>(); if (!subscribers.Contains(callback)) subscribers.Remove(callback); return true; } catch { return false; } } } } I was thinking I could do something like this but I don't know how to pass the message string from AddMessage to DoSomething... Dim subscribers As New List(Of IMessageCallback) Public Sub AddMessage(ByVal message As String) Implements IMessage.AddMessage Dim action As Action(Of IMessageCallback) action = AddressOf DoSomething subscribers.ForEach(action) 'Or this instead of the above three lines: 'subscribers.ForEach(AddressOf DoSomething) End Sub Public Sub DoSomething(ByVal callback As IMessageCallback) 'I am also confused by: '((ICommunicationObject)callback).State 'Is that casting the callback object as type ICommunicationObject? 'How is that done in VB? End Sub

    Read the article

  • [iPhone] How to control other buttons' actions?

    - by Devoted
    Hi so say I have this code: UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Yay" message: msg delegate: self cancelButtonTitle: @"Proceed..." otherButtonTitles: @"1", @"2", nil]; How do I control the other buttons "1" and "2"? (Suppose all other necessary code is in place, such as the undefined variable msg) Thanks!

    Read the article

  • Retrieving Data in A NSTableView

    - by Heisennberg
    I have a three column Table View populated by two NSMutableDictionaries which share the same keys (ie key | value1 | value2 ) with dict1(key,value1) and dict2(key,value2). I want to manually enter data in the third column and create the key/value objects in dict2. But when I do that, my code picks the wrong key :S Here's the code for the delegate : - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { if ([[aTableColumn identifier] isEqualToString:@"value2"]) { [dict2 setValue:anObject forKey:[[[aTableView tableColumnWithIdentifier:@"key"] dataCellForRow:rowIndex] stringValue ]]; } } Any idea ?

    Read the article

  • .NET Threading : How to wait for other thread to finish some task

    - by Alex Ilyin
    Assume I have method void SomeMethod(Action callback) This method does some work in background thread and then invokes callback. The question is - how to block current thread until callback is called ? There is an example bool finished = false; SomeMethod(delegate{ finished = true; }); while(!finished) Thread.Sleep(); But I'm sure there should be better way

    Read the article

< Previous Page | 41 42 43 44 45 46 47 48 49 50 51 52  | Next Page >