Jump to content

tappatappa

uniGUI Subscriber
  • Posts

    333
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by tappatappa

  1. Hello ZigZig,

     

    I am trying. Is not remotely as easy as I hoped :) Moreover, I guess I have to make it more flexible by retrieving the uniGUI/extjs version from ServerModule.

     

    How do I have to change the path in Stand Alone Server mode (I see you refer to the dll in the paths)?

  2. In MegaDemo

    procedure TMainForm.ThemeClick(Sender: TObject);
    begin
      if UniApplication<>nil then
      begin
        UniServerModule.Lock;
        try
          case TComponent(Sender).Tag of
            1 : UniServerModule.CurrentTheme:='blue';
            2 : UniServerModule.CurrentTheme:='gray';
            3 : UniServerModule.CurrentTheme:='classic';
            4 : UniServerModule.CurrentTheme:='xp';
            5 : UniServerModule.CurrentTheme:='vista';
          end;
        finally
          UniServerModule.UnLock;
        end;
        TUniGUIApplication(UniApplication).Restart;
      end;
    end;
    

    Is it possible to implement a similar feature without changing UniServerModule and restarting the Application?

  3. ok I wrote a shell script that generates the cbproj file

     

    sed -e 's/<AppType>Application<\/AppType>/<AppType>Library<\/AppType>/g' \
    -e "s/<Config Condition=\"'\$(Config)'==''\">Debug<\/Config>/<Config Condition=\"'\$(Config)'==''\">Release<\/Config>/g" \
    -e 's/<ProjectType>CppVCLApplication<\/ProjectType>/<ProjectType>CppManagedDynamicLibrary<\/ProjectType>/g' \
    -e 's/<Borland\.ProjectType>CppVCLApplication<\/Borland\.ProjectType>/<Borland.ProjectType>CppManagedDynamicLibrary<\/Borland.ProjectType>/g' \
    -e 's/<ProjectGuid>{[a-zA-Z0-9\-]*}<\/ProjectGuid>/<ProjectGuid>{3D9AD1F9-86F9-468A-AE84-AA46B52285E8}<\/ProjectGuid>/g'\
     < myproject.cbproj > myproject_DLL.cbproj 
    

    plus you need to put some #ifdef here and there, especially in the MainSource (myproject.cpp)

    #ifdef MYPROJECT_DLL
    
    #include <ActiveX.hpp>
    #include <ComObj.hpp>
    #include <UniGUIISAPI.hpp>
    #include <Isapi2.hpp>
    #else
    #include <UniGUIVars.hpp>
    #endif
    
    //.....USEFORM.....
    
    #ifdef MYPROJECT_DLL
    #pragma link "uniguiisapi.obj"
    #else
    #pragma link "UniGUIVars.obj"
    #pragma MyProject
    #endif
    #pragma package(smart_init)
    
    #ifdef MYPROJECT_DLL
    
    #define __DLL_OBFUSCATE(a, a##b
    //---------------------------------------------------------------------------
    int WINAPI __DLL_OBFUSCATE(DllEnt,ryPoint) (HINSTANCE hinst, unsigned long reason, void*)
    {
      try
      {
    	if (reason == DLL_PROCESS_ATTACH) {
          CoInitFlags = COINIT_MULTITHREADED;
        }
      }
      catch (Exception &exception)
      {
      }
      return 1;
    }
    //---------------------------------------------------------------------------
    extern "C"
    {
      BOOL __declspec(dllexport) WINAPI GetExtensionVersion(Isapi2::THSE_VERSION_INFO &Ver)
      {
    	return Uniguiisapi::GetExtensionVersion(Ver);
      }
      //---------------------------------------------------------------------------
      unsigned __declspec(dllexport) WINAPI HttpExtensionProc(Isapi2::TEXTENSION_CONTROL_BLOCK &ECB)
      {
    	return Uniguiisapi::HttpExtensionProc(ECB);
      }
      //---------------------------------------------------------------------------
      BOOL __declspec(dllexport) WINAPI TerminateExtension(int dwFlags)
      {
        return Uniguiisapi::TerminateExtension(dwFlags);
      }
    }
    #else
    //---------------------------------------------------------------------------
    WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
    {
    	try
    	{
    		Forms::Application->Initialize();
    		Uniguivars::CreateServerModule(__classid(TUniServerModule));
    		Application->Run();
    	}
    	catch (...)
    	{
    	}
    	return 0;
    }
    #endif
    
  4. I was wondering whether is possible to write a c++builder project (.cbproj) where you can produce a Stand-Alone Application (.exe) with the Debug Configuration, and a ISAPI DLL with the Release Configuration. Currently I work with two separate projects but this is painful because when I add a new unit to the "Debug project" I have to remember to add it to the "Release project", too. This rarely happens, of course, and causes all sorts of problems during release (compiling/linking/runtime errors...)

     

    Beside auto-generating the .cbproj, what alternatives do I have?

  5. I don't know if is a missing feature, but I can't read the tshiftstate in a OnMouseDown event

    void __fastcall TFrame1::UniCanvasMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y)
    {
    	if (Shift.Contains(ssShift))
    		//do stuff
    	else
    		//do other stuff
    }
    

    the code above always executes the "else" branch. Any ideas / workarounds?

  6. Delphi Developer, you are my hero.

     

    Ok now I suspect that I have introduced a weird glitch in the datetimepicker: I have to click 2 times on the day to make the calendar disappear. Do you experience the same thing?

  7. I am trying to implement date ranges using uniGUI Date Time Pickers. I am following this guide

     

    I am almost finished, but I am facing a big problem. I hope someone can help!

     

    Step 1 (VTypes and daterange, copy/paste from the article):

    	UniSession()->AddJS(L" Ext.apply(Ext.form.VTypes,\
    	{ daterange : function(val, field)\
    		  {\
    			var date = field.parseDate(val);\
    			if(!date){return false;}\
    			if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime())))\
    			{\
    			   var start = Ext.getCmp(field.startDateField);\
    			   start.setMaxValue(date);\
    			   start.validate();\
    			   field.dateRangeMax = date;\
    			}\
    			else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime())))\
    			{\
    			   var end = Ext.getCmp(field.endDateField);\
    			   end.setMinValue(date);\
    			   end.validate();\
    			   field.dateRangeMin = date;\
    			}\
    			return true;\
    		  },\
    	});");
    

    Step 2 (beforeInit):

    dtp_START->ClientEvents->UniEvents->Values[L"beforeInit"] = L" function(sender)\
    		{\
    				Ext.apply(sender, {\
    				vtype: 'daterange',\
    				endDateField: '"+dtp_FINAL->JSName+L"'\
    				});\
    		}";
    dtp_FINAL->ClientEvents->UniEvents->Values[L"beforeInit"] = L" function(sender)\
    		{\
    				Ext.apply(sender, {\
    				vtype: 'daterange',\
    				startDateField: '"+dtp_START->JSName+L"'\
    				});\
    		}";
    

    ....and here is the problem. JSName is always NULL at this point. I don't know if it is a bug or is because how uniGUI works.

    So, i tried this workaround

    
    dtp_START->ClientEvents->UniEvents->Values[L"beforeInit"] = L" function(sender)\
    		{\
    		    if("+form->Name+L"[\""+dtp_FINAL->Name+L"\"])\
    			{\
    				Ext.apply(sender, {\
    				vtype: 'daterange',\
    				endDateField: "+form->Name+L"[\""+dtp_FINAL->Name+L"\"].id\
    				});\
    			}\
    		}";
    dtp_FINAL->ClientEvents->UniEvents->Values[L"beforeInit"] = L" function(sender)\
    		{\
    			if("+form->Name+L"[\""+dtp_START->Name+L"\"])\
    			{\
         			Ext.apply(sender, {\
    				vtype: 'daterange',\
    				startDateField: "+form->Name+L"[\""+dtp_START->Name+L"\"].id\
    				});\
    			}\	
    		}";
    

    but this is not enough, since the Ext.appy is called only for the SECOND picker that is initialized. As a result, only one datetimepicker is constrained.

     

    Calling Ext.apply for BOTH pickers in both beforeInit events doesn't help, since only one datetimepicker (the sender) is initialized correclty anyway.

     

    HELP! :excl:

     

     

  8. You are on the right track, look at the attached example.

     

    Thanks for your reply. In order to make it work for a single SpeedButton I had to implement a little trick

    void __fastcall TForm1::ButtonSpeedAClick(TObject *Sender)
    {
    	static bool speedAstate = false;
    	ButtonSpeedA->Down = !speedAstate;
    	speedAstate = !speedAstate;
    }
    
  9. Can someone explain to me how does UniSpeedButton->Down works?

    My guess is that SpeedButton has two states (Down and Up) and can be used as a "checkbox" (Checked true/false), but

    void __fastcall TForm1::ButtonSpeedClick(TObject *Sender)
    {
    	ButtonSpeed->Down = !ButtonSpeed->Down;
    }
    

    does nothing (graphically)

  10. Please, port source code to Delphi.

    :D

     

    Come on! Is non THAT hard! :)

     

    For starters, here is a quick and dirty port (I am not even sure that compiles). If you can improve it please reply with your solution.

    procedure fixDateTimePicker(dt:TUniCustomDateTimePicker)
    var
    	dtp:   TUniDateTimePicker;
    	dbdtp: TUniDBDateTimePicker;
    	kind: TUniDateTimeKind;
    	ev: string;
    begin
    	dtp := nil;
    	dbdtp := nil;
    	
    	if dt is TUniDateTimePicker then
    	begin
    		dtp := dt as TUniDateTimePicker;
    		kind := dtp.Kind;
    	end
    	elsif dt is TUniDBDateTimePicker then
    	begin
    		dbdtp := dt as TUniDBDateTimePicker;
    		kind := dbdtp.Kind;
    	end
    	else
    		Exit;
    	
            ev := ' function(sender) { sender.editable = false; }';
    
    	if (kind = tUniDate) or (kind = tUniTime) then 
    	begin
    		if (dtp <> nil) then
    			dtp.ClientEvents.ExtEvents.Values['afterrender'] := ev
    		elsif (dbdtp <> nil) then
    			dbdtp.ClientEvents.ExtEvents.Values['afterrender'] := ev;
    	end
    	else
    	begin
    		if (dtp <> nil) then
    		begin
    			dtp.ClientEvents.ExtEvents.Values['date.afterrender'] := ev;
    			dbdtp.ClientEvents.ExtEvents.Values['time.afterrender'] := ev;
    		end
    		elsif (dbdtp <> nil) then
    		begin
    			dtp.ClientEvents.ExtEvents.Values['date.afterrender'] := ev;
    			dbdtp.ClientEvents.ExtEvents.Values['time.afterrender'] := ev;
    		end;
    	end;
    end;
    
    • Upvote 1
  11. static void fixDateTimePicker(TUniCustomDateTimePicker * dt)
    {
    	TUniDateTimePicker * dtp = dynamic_cast<TUniDateTimePicker*>(dt);
    	TUniDBDateTimePicker * dbdtp = dynamic_cast<TUniDBDateTimePicker*>(dt);
    	TUniDateTimeKind kind;
    	if (dtp != NULL)
    		kind = dtp->Kind;
    	else if (dbdtp != NULL)
    		kind = dbdtp->Kind;
    	else
    		return;
    	
            UnicodeString ev = L" function(sender) { sender.editable = false; }";
    
    	if (kind == tUniDate || kind == tUniTime)
    	{
    		if (dtp != NULL)
    			dtp->ClientEvents->ExtEvents->Values[L"afterrender"] = ev;
    		else if (dbdtp != NULL)
    			dbdtp->ClientEvents->ExtEvents->Values[L"afterrender"] = ev;
    	}
    	else
    	{
    		if (dtp != NULL)
    		{
    			dtp->ClientEvents->ExtEvents->Values[L"date.afterrender"] = ev;
    			dtp->ClientEvents->ExtEvents->Values[L"time.afterrender"] = ev;
    		}
    		else if (dbdtp != NULL)
    		{
    			dbdtp->ClientEvents->ExtEvents->Values[L"date.afterrender"] = ev;
    			dbdtp->ClientEvents->ExtEvents->Values[L"time.afterrender"] = ev;
    		}
    	}
    }
    

    this works for both DB and non-DB components.

  12. void __fastcall TMainForm::UniFormShow(TObject *Sender)
    {
    
    TDateTime dtTime1 = StrToTime(L"00:00:00");
    TDateTime dtTime2 = StrToTime(L"23:59:59");
    
    UniDateTimePicker1->DateTime = TDateTime::CurrentDate() - 1 + dtTime1;
    UniDateTimePicker2->DateTime= TDateTime::CurrentDate() + dtTime2;
    
    }
    
    
    

    You have to assign values to DateTimePicker->DateTime

×
×
  • Create New...