Posts

java - How do you write an extra class for often used code and call it from everywhere? -

in little app users can have @ 'more information' or send me feedback when click on the menu button (of device) @ every xml file of app. this code (when click on menu button): @override public boolean oncreateoptionsmenu(menu menu) { getmenuinflater().inflate(r.menu.menu, menu); return super.oncreateoptionsmenu(menu); } @override public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.impressum: startactivity(new intent (this, moreinformation.class)); break; case r.id.feedback: /* * */ break; } return super.onoptionsitemselected(item); } now put code java classes. works i'd create class (let's call ismenubuttonpressed.class ) contains code above , i'd remove code above other java classes , call ismenubuttonpressed.class (in these java classes when menu button pressed). how can that? how pass informati...

c++ - Disadvantages of passing around functions? -

i'm learning c++ (coming java) , discovered can pass functions around. cool , think immensely useful. thinking on how use , 1 of idea's popped head customizable class. the best example of train of though customizable classes (code) person class. person have functions pertaining p. later person may pick sword (s), person has access functions pertaining both p , s. are there limits or performance issues this? sloppy , plain frowned upon? any insight educational, thanks. ~aedon there slight performance hit since pointer or reference must dereferenced before calling function. this advantageous feature. many design patterns , polymorphism depend on pointers functions. check out "visitor design pattern". another usage table of functions. example, write generic menu engine displays different menus using different functions. also research "factory design pattern."

java - JTabbedPane: How to restrict user from moving out of current tab -

how can restrict user going away current tab. need show confirmation message save/discard changes before leaving current tab. how can implement functionality in jtabbedpane? you override setselectedindex in jtabbedpane object, called before change takes place. if this, remember call super.setselectedindex after displayed confirmation. alternatively, eng.fouad states, add changelistener , display confirmation message there, happens after tab has been changed, confirmation message display after new tab has been displayed on screen: http://www.java2s.com/tutorial/java/0240__swing/listeningforselectedtabchanges.htm the second option easier implement if can live fact new tab displayed when confirmation pops up.

flex - CollapsibleAccordion label not visible problem when migrated from Flex3 to Flex4 -

the collapsibleaccordion. have 2 canvas inside collapsibleaccordion, , works fine, problem unable see labels when migrated code flex4 flex3. the code problem below: <mx:application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:cal="cal.*" layout="absolute" addedtostage="stage_init()" applicationcomplete="init()" xmlns:geometry="com.degrafa.geometry.*" xmlns:degrafa="com.degrafa.*" xmlns:paint="com.degrafa.paint.*" xmlns:containers="flexlib.containers.*" xmlns:flexlib_controls="flexlib.controls.*" xmlns:mdi_containers="flexlib.mdi.containers.*" xmlns:auto="com.hillelcoren.components.*" xmlns:local="*" backgroundcolor="#f7fafe" backgroundgradientcolors="[#f7fafe, #6caaeb]" xmln...

c++ - WIndows service run desktop program in Remote Desktop -

i need launch program in remote desktop, program open window , need user interact, application windows service. i'm using windows 2008. i'm created application success launch program session connect mouse, keyboard, need launch in rdp. now i'm using these functions. wtsenumeratesessions (enum sessions, here know if rdp) wtsqueryusertoken (get user token) duplicatetokenex ( make primary token) createprocessasuser (run application si.lpdesktop = _t("winsta0\\default")) but work success run application in console connect keyboard, mouse, monitor, not rdp. anyway can me ? thanks. so you're trying launch gui application in particular rdp session on machine? have right idea, more or less, though may missing few pieces. take @ processhelper class in source automated tests of cassia library . can remove lot of managed cruft use in c++. can omit gettokeninformation( ...tokeninformationclass.tokenlinkedtoken... ) nonsense if don't need run pr...

c++ - How to re-route std::clog in another CRT lib? -

i have win32 program that's built vs2008, code linked msvcr90.dll , msvcp90.dll. however, it's running code in dll (which can't modify) that's been built vs2005 , when code in dll prints clog stream via msvcr80.dll , msvcp80.dll. here's problem: if re-route std::clog in code, affect code built against crt 9.0 libs, code using older crt 8.0 wont have output re-routed. there way re-route clog stream in dll built against older crt? i've investigated calling getmodulehandle() , getprocaddress() on older crt dlls , have managed re-route c stderr stream (via _open_osfhandle , _dup2), c++ clog stream still seems unaffected. think need call ios_base::sync_with_stdio() in older crt lib couldn't valid address function. appreciated. thanks. build helper dll using vs2005 - dll should export functions setup need vs8 runtime.

android - Keeping a reference to gl in GLSurfaceView::onSurfaceCreated? -

is safe keep reference gl10 gl parameter when glsurfaceview::onsurfacecreated called? i'd initialize textures @ point later onsurfacecreated don't know now, wondered if keeping reference ok. i think bad idea. can bind textures in glsurfaceview.renderer::ondrawframe.