Daily Archives

Articles indexed Wednesday May 26 2010

Page 30/118 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • When do I need to deallocate memory?

    - by extintor
    I am using this code inside a class to make a webbrowser control visit a website: void myClass::visitWeb(const char *url) { WCHAR buffer[MAX_LEN]; ZeroMemory(buffer, sizeof(buffer)); MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, url, strlen(url), buffer, sizeof(buffer)-1); VARIANT vURL; vURL.vt = VT_BSTR; vURL.bstrVal = SysAllocString(buffer); // webbrowser navigate code... VariantClear(&vURL); } I call visitWeb from another void function that gets called on the handlemessage() for the app. Do I need to do some memory deallocation here?, I see vURL is being deallocated by VariantClear but should I deallocate memory for buffer? I've been told that in another bool I have in the same app I shouldn't deallocate anything because everything clear out when the bool return true/false, but what happens on this void?

    Read the article

  • DRY Authenticated Tasks in Cocoa (with distributed objects)

    - by arbales
    I'm kind of surprise/infuriated that the only way for me to run an authenticated task, like perhaps sudo gem install shi*t, is to make a tool with pre-written code. I'm writing a MacRuby application, which doesn't seem to expose the KAuthorization* constants/methods. So.. I learned Cocoa and Objective-C. My application creates a object, serves it and calls the a tool that elevates itself and then performs a selector on a distributed object (in the tool's thread). I hoped that the distributed object's methods would evaluated inside the tool, so I could use delegation to create "privileged" tasks. If this won't work, don't try to save it, I just want a DRY/cocoa solution. AuthHelper.m //AuthorizationExecuteWithPrivileges of this. AuthResponder* my_responder = [AuthResponder sharedResponder]; // Gets the proxy object (and it's delegate) NSString *selector = [NSString stringWithUTF8String:argv[3]]; NSLog(@"Performing selector: %@", selector); setuid(0); if ([[my_responder delegate] respondsToSelector:NSSelectorFromString(selector)]){ [[my_responder delegate] performSelectorOnMainThread:NSSelectorFromString(selector) withObject:nil waitUntilDone:YES]; } RandomController.m - (void)awakeFromNib { helperToolPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/AuthHelper"]; delegatePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingString:@"/ABExtensions.rb"]; AuthResponder* my_responder = [AuthResponder initAsService]; [my_responder setDelegate:self]; } -(oneway void)install_gems{ NSArray *args = [NSArray arrayWithObjects: @"gem", @"install", @"sinatra", nil]; [NSTask launchedTaskWithLaunchPath:@"/usr/bin/sudo" arguments:args]; NSLog(@"Ran AuthResponder.delegate.install_gems"); // This prints. } ... other privileges tasks. "sudo gem update --system" for one. I'm guessing the proxy object is performing the selector in it's own thread, but I want the current (privileged thread) to do it so I can use sudo. Can I force the distributed object to evaluate the selector on the tool's thread? How else can I accomplish this dryly/cocoaly?

    Read the article

  • Link XSL Style Sheet to XForms generated XML document

    - by iHeartGreek
    Hi! Through XForms, I generate an XML document. I need this XML document to be transformed by a specific XSL. How do I link the XSL to the XML through XForms? Example of link: <?xml-stylesheet type="text/xsl" href="test.xsl"?> (The XML doc gets regenerated every time the XForms submits to it.. so I cannot hardcode the link in the XML doc, in needs to be done through the XForms) Thanks!

    Read the article

  • Reading long lines from text file

    - by sonofdelphi
    I am using the following code for reading lines from a text-file. What is the best method for handling the case where the line is greater than the limit SIZE_MAX_LINE? void TextFileReader::read(string inFilename) { ifstream xInFile(inFilename.c_str()); if(!xInFile){ return; } char acLine[SIZE_MAX_LINE + 1]; while(xInFile){ xInFile.getline(acLine, SIZE_MAX_LINE); if(xInFile){ m_sStream.append(acLine); //Appending read line to string } } xInFile.close(); }

    Read the article

  • Adding custom perfomance counters in ASP.Net for service calls

    - by Nithin
    Hi All, I have to show the time taken for a service call in Perfmon from my ASP.Net application. For this, I have added a stopwatch which starts at the service call start and stops at service call stop. Now I have a custom counter which user AverageTimer32 to log the stopwatch values to Perfmon. My question is, how can I show the service names on the Perfmon graph. I am using windows XP (I know windows server perfmon has some fancy stuff).

    Read the article

  • Why do we need to use ConvertBack in IValue Converter

    - by Subhen
    Hi, I am not sure Why we need to use I ConvertBack method in IValueConverter. In the Convert method itself we do the conversion and return the updated value to be bound in our control. So in which Scenario we should use Convertback. I know this question is very basic but just wanted to make the fundamentals clear. Thanks a lot for your help and suggestions. Thanks, Subhen

    Read the article

  • Solution for Numeric Text Field in GWT

    - by Ashwin Prabhu
    I need a text field very similar in behavior to Gxt's NumberField. Unfortunately I am not using Gxt in my application and GWT 2.0 does not have a Numeric text field implementation as yet. So that currently leaves me with an option to simulate a NumberField by filtering out non-numeric keystrokes using a keyboardHandler. Is this the the best way to approach the problem? Does anyone here have a better solution/approach in mind? Thanks in advance :)

    Read the article

  • php won't detect all spaces in a string...

    - by user296516
    Hi guys, I've got a string that comes from a POST form where I want to replace all spaced with some other character. Here's that I did: $cdata = str_replace(" ","#",$cdata); And I got this. --- Contact-ID#=#148 [10274da8]#Sinhronizacija#=#private [1000137d]#Uzvards#=#Zom [1000137c]#Vards#=#Tana [1000130e]#Talrunis#=#3333 [1000130e]#Mobilais#=#5555 As you can see, spaced before "[10..." are still there. Any ideas what could be the problem?

    Read the article

  • Does anyone get zero-height select fields in Firefox 3.6.3?

    - by user350635
    If you open this HTML in Firefox 3.6.3 (confirmed in some earlier versions too), and click the drawStuff() link repeatedly, it doesn't render the contents of the last div consistently. Looking more closely it seems like it's rendering select fields with height=0. Any idea why this would happen? <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title> A Page </title> <script type="text/javascript"> function drawStuff() { for (var i = 1; i <= 5; i++) { var curHtmlArr = []; for (var j = 0; j < 5; j++){ curHtmlArr.push("<select>"); curHtmlArr.push(getOptgroup()); curHtmlArr.push(getOptgroup()); curHtmlArr.push(getOptgroup()); curHtmlArr.push("<\/select>"); } var foobar = document.getElementById('elem_' + i); foobar.innerHTML = curHtmlArr.join(''); } } function getOptgroup(){ var htmlArr = []; htmlArr.push('<optgroup label="Whatever">'); for (var ii = 0; ii < 32; ii++){ htmlArr.push(' <option value="' + ii + '"> Blah ' + "<\/option>"); } htmlArr.push("<\/optgroup>"); return htmlArr.join(''); } </script> </head> <body> <table border=1 style="width:900px;" summary="A Table"> <tr> <td> <div id="elem_1"></div> </td> <td> <div id="elem_2"></div> </td> <td> <div id="elem_3"></div> </td> <td> <div id="elem_4"></div> </td> <td> <div>abc</div> <div id="elem_5"></div> </td> </tr> </table> <a href="javascript:drawStuff()"> drawStuff() </a> <script type="text/javascript"> drawStuff(); </script> </body> </html>

    Read the article

  • Logging in MVC (Zend Framework)

    - by superdario
    Is there a best-practice when it comes to where to put the logging functionality in an MVC application, for example a Zend Framework application (Zend_Log)? Should I put the logging in the controller or in the model? Or in both? If in both, should they have the same logger or a separate one?

    Read the article

  • NavigationBar from UINavigationController not positioned correctly

    - by David Liu
    So, my iPad program has a pseudo-split view controller (one that I implemented, not base SDK one), and was working correctly a while ago. It has the basic layout (UINavController for master, content view controller for detail on right), but I have it so the master view doesn't disappear when rotated into portrait view. Recently, I added in a UITabBarController to contain the entire split view, which has made the navigation bar go wonky, while all the other views are positioned fine. In addition, the navigation bar only gets mispositioned when the program starts up while the iPad is in landscape, or upside-down portrait. If it starts out in portrait, everything is fine. Relevant Code: RootViewController.m: - (void)loadView { navController = [[NavigationBreadcrumbsController_Pad alloc] init]; ABTableViewController_Pad * tableViewController = [[ABTableViewController_Pad alloc] initWithNibName:@"ABTableView"]; master = [[UINavigationController_Pad alloc] initWithRootViewController:tableViewController]; [tableViewController release]; // Dummy blank UIViewcontroller detail = [[UIViewController alloc] init]; detail.view = [[[UIView alloc] init] autorelease]; [detail.view setBackgroundColor:[UIColor grayColor]]; self.view = [[[UIView alloc] init] autorelease]; self.view.backgroundColor = [UIColor blackColor]; [self positionViews]; [self.view addSubview:navToolbarController.view]; [self.view addSubview:master.view]; [self.view addSubview:detail.view]; } // Handles the respositioning of view into it's current orientation -(void)positionViews{ CGFloat tabBarOffset = 0; if(self.tabBarController){ tabBarOffset = self.tabBarController.tabBar.frame.size.height; } if(self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) { self.view.frame = CGRectMake(0, 0, 768, 1004); navController.view.frame = CGRectMake(0,0,768,44); //adjust master view [master.view setFrame:CGRectMake(0, 44, 320, 1024 - 44 - 20 - tabBarOffset)]; //adjust detail view [detail.view setFrame:CGRectMake(321,44, 448, 1024 - 44 - 20 - tabBarOffset)]; } // Landscape Layout else{ self.view.frame = CGRectMake(0, 0, 748, 1024); navToolbarController.view.frame = CGRectMake(0,0,1024,44); //adjust master view [master.view setFrame:CGRectMake(0, 44, 320, 768 - 44 - 20 - tabBarOffset)]; //adjust detail view [detail.view setFrame:CGRectMake(321,44, 1024 - 320, 768 - 44 - 20 - tabBarOffset)]; } }

    Read the article

  • where can i get Request.Browser.Platform items from ?

    - by eugeneK
    Hi, i want to have pre-made list of most common OSes in my DB and all non default to be listed as other. Problem is i don't know what OSes called in Request.Browser object. List i want to have WinXP, Vista, Win7, Linux, MacOS and other... Do any of you know what are exact names of these OSes in Request.Browser.Platform or where i can get list of values from ?

    Read the article

  • How to develop my own sms Gateway ?

    - by waheed
    I intend to develop an SMS gateway in c#, but i am doubtful about it's feasibility, because my initial research had shown that an SMS gateway had to cover for protocol differences. So what exactly a gateway had to do, further if i use SMPP, so is it possible to send/receive SMS to/from any number in the world by simply using SMPP ?

    Read the article

  • Why doesn't line-height work on FF/3.5.8(Mac)?

    - by Znarkus
    I can't get line-height on a text input to work on Firefox 3.5.8/(Mac). Works flawlessly on: IE6 IE7 IE8 FF3.6/PC FF3.6/Mac Safari Test code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>asd</title> <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.0r4/build/reset/reset-min.css" /> </head> <body> <input type="text" value="Hello" style="line-height:50px;height:50px;font-size:16px;" /> <input type="text" value="Hello" style="padding:17px 0;font-size:16px;" /> </body> </html> Is there an alternate solution or any idea how to fix this? Edit: Updated the test code, to compare line-height vs. padding technique. Padding works on all above browsers except IE8. Whaat? I can't test on FF/3.5.8 anymore, could someone please report the result from this browser on any plattform? I'm now thinking this is a Firefox 3.5.8 issue, plattform independent.

    Read the article

  • jQuery arrays - newbie needs a kick start

    - by Jonny Wood
    I've only really started using this site and alredy I am very impressed by the community here! This is my third question in less than three days. Hopefully I'll be able to start answering questions soon instead of just asking them! I'm fairly new to jQuery and can't find a decent tutorial on Arrays. I'd like to be able to create an array that targets several ID's on my page and performs the same effect for each. For example I have tabs set up with the following: $('.tabs div.tab').hide(); $('.tabs div:first').show(); $('.tabs ul li:first a').addClass('current'); $('.tabs ul li a').click(function(){ $('.tabs ul li a').removeClass('current'); $(this).addClass('current'); var currentTab = $(this).attr('href'); $('.tabs div.tab').hide(); $(currentTab).show(); return false; }); I've used the class .tag to target the tabs as there are several sets on the same page, but I've heard jQuery works much faster when targetting ID's How would I add an array to the above code to target 4 different ID's? I've looked at var myArray = new Array('#id1', 'id2', 'id3', 'id4'); And also var myValues = [ '#id1', 'id2', 'id3', 'id4' ]; Which is correct and how do I then use the array in the code for my tabs...?

    Read the article

  • Django, Redirecting staff from login to the admin site.

    - by Francisco Gomez
    So my site basically has 2 kinds of ways to login, one of them is for the common users, who get the regular screen that asks them for username and password, the other way its for staff. The staff login should redirect them to the admin site after logging in, but for some reason the redirect doesnt happen, it stays on the same login page. I use this condition on the login view. if user is not None and user.is_active and user.is_staff: auth.login(request,user) return HttpResponseRedirect("/admin/") The admin site its up and running in my url configuration and everything, but i dont know if this is the correct way to redirect to the admin site already on session. Thanks, any help would be appreciated.

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >