How to use #include with panel type window in extendscript? - extendscript

#targetengine main
#include "test.jsx"
var w = new Window("palette");
w.show();
..basically that, #include seems to stop panel window launching, what I am doing wrong/how to get around this?

Try this work around:
#targetengine main
var ip = new File($.fileName);
var scriptPath = ip.path;
function incScript(sn) {
eval('#includepath ' + scriptPath + '\n#include ' + sn);
}
incScript('test.jsx');
var w = new Window("palette");
w.show();
Based on : https://community.adobe.com/t5/illustrator/script-created-illustrator-palette-disappears-when-in-the-presence-of-include/m-p/9501010

Related

WxWidgets - open new frame from button click

I'm using CodeBlocks as IDE with WxWidgets in order to develop a simple application based on buttons actions: the user can click on different buttons to get information from the system.
I would like to open a new frame when a button is clicked, but I do not know how to do it since I'm still a newby and I couldn't find any tutorial about this topic.
How can I create and launch a new frame when Button1 is clicked?
If you can't help me, can you at least give me some good link where I can understand how to do this, please?
How can I create and launch a new frame when Button1 is clicked?
Thank you for your support!
This is my basic code:
isolaApp.cpp
#include "isolaApp.h"
//(*AppHeaders
#include "isolaMain.h"
#include <wx/image.h>
//*)
IMPLEMENT_APP(isolaApp);
bool isolaApp::OnInit()
{
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
isolaFrame* Frame = new isolaFrame(1);
Frame->Show();
SetTopWindow(Frame);
}
return wxsOK;
}
isolaMain.cpp
#include "isolaMain.h"
#include <wx/msgdlg.h>
//(*InternalHeaders(isolaFrame)
#include <wx/intl.h>
#include <wx/string.h>
//*)
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(isolaFrame)
const long isolaFrame::ID_BUTTON1 = wxNewId();
const long isolaFrame::ID_BUTTON2 = wxNewId();
const long isolaFrame::ID_SASHWINDOW1 = wxNewId();
const long isolaFrame::idMenuQuit = wxNewId();
const long isolaFrame::idMenuAbout = wxNewId();
const long isolaFrame::ID_STATUSBAR1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(isolaFrame,wxFrame)
//(*EventTable(isolaFrame)
//*)
END_EVENT_TABLE()
isolaFrame::isolaFrame(wxWindow* parent,wxWindowID id)
{
//(*Initialize(isolaFrame)
wxMenu* Menu1;
wxMenu* Menu2;
wxMenuBar* MenuBar1;
wxMenuItem* MenuItem1;
wxMenuItem* MenuItem2;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("id"));
SashWindow1 = new wxSashWindow(this, ID_SASHWINDOW1, wxPoint(168,72), wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN, _T("ID_SASHWINDOW1"));
Button1 = new wxButton(SashWindow1, ID_BUTTON1, _("Label"), wxPoint(143,163), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
Button2 = new wxButton(SashWindow1, ID_BUTTON2, _("Label"), wxPoint(143,225), wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
SashWindow1->SetSashVisible(wxSASH_TOP, true);
SashWindow1->SetSashVisible(wxSASH_BOTTOM, true);
SashWindow1->SetSashVisible(wxSASH_LEFT, true);
SashWindow1->SetSashVisible(wxSASH_RIGHT, true);
MenuBar1 = new wxMenuBar();
Menu1 = new wxMenu();
MenuItem1 = new wxMenuItem(Menu1, idMenuQuit, _("Quit\tAlt-F4"), _("Quit the application"), wxITEM_NORMAL);
Menu1->Append(MenuItem1);
MenuBar1->Append(Menu1, _("&File"));
Menu2 = new wxMenu();
MenuItem2 = new wxMenuItem(Menu2, idMenuAbout, _("About\tF1"), _("Show info about this application"), wxITEM_NORMAL);
Menu2->Append(MenuItem2);
MenuBar1->Append(Menu2, _("Help"));
SetMenuBar(MenuBar1);
StatusBar1 = new wxStatusBar(this, ID_STATUSBAR1, 0, _T("ID_STATUSBAR1"));
int __wxStatusBarWidths_1[1] = { -1 };
int __wxStatusBarStyles_1[1] = { wxSB_NORMAL };
StatusBar1->SetFieldsCount(1,__wxStatusBarWidths_1);
StatusBar1->SetStatusStyles(1,__wxStatusBarStyles_1);
SetStatusBar(StatusBar1);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&isolaFrame::OnButton1Click);
Connect(idMenuQuit,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&isolaFrame::OnQuit);
Connect(idMenuAbout,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&isolaFrame::OnAbout);
//*)
}
isolaFrame::~isolaFrame()
{
//(*Destroy(isolaFrame)
//*)
}
void isolaFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void isolaFrame::OnAbout(wxCommandEvent& event)
{
wxString msg = wxbuildinfo(long_f);
wxMessageBox(msg, _("Welcome to..."));
}
void isolaFrame::OnButton1Click(wxCommandEvent& event)
{
// I want to show a new
}
To show a new frame, you just need to create it and then Show() it: the last step is important, as new frames are created initially hidden, so if you forget to call Show(), the frame will exist but neither you nor the users of your application will see it.

seriesmarks is not visible for specified valueindex in teechart2017

In VS2013,teechart2017.ocx,
I make a dialog based MFC project.
I add a teechart on the dialog, changed the property of mark to
display value,set drawevery to 1,visible,not autoposition.
I used getserismark event to display only specified marks.
I add 20000 point in series0,
if i used teechart8, it display correctly,but for teechart2017,the
marks disappeared for all.
void CMFCApplication2Dlg::OnGetSeriesMarkTchart1(long SeriesIndex, long ValueIndex, BSTR* MarkText)
{
// TODO:
if (B_Filter)
{
if ((ValueIndex == 1250) || (ValueIndex == 137)|| (ValueIndex == 10000))
{
}
else
{
m_Chart1.Series(SeriesIndex).GetMarks().GetItem(ValueIndex).SetVisible(false);
}
}
I've reproduced the problem (#1986) and I've added the CalcVisiblePoints property for the next maintenance release.
There was an optimization introduced in v2016.0.0.1 that is causing this issue. You have to set TChart1.Series(0).CalcVisiblePoints = False to skip that optimization and make it work as in v8.
With the new v2018.0.2.9 you can do this:
#include "CAspect.h"
#include "CLegend.h"
#include "CSeries.h"
#include "TeeChartDefines.h"
#include "CMarks.h"
#include "CMarksItem.h"
//...
CAspect a = mChart1.get_Aspect();
a.put_View3D(false);
CLegend l = mChart1.get_Legend();
l.put_Visible(false);
mChart1.AddSeries(scFastLine);
CSeries s = mChart1.Series(0);
s.FillSampleValues(20000);
CMarks sm = s.get_Marks();
sm.put_Visible(true);
for (int i = 0; i < s.get_Count(); i++) {
CMarksItem smi = sm.get_Item(i);
smi.put_Visible((i == 1250) || (i == 137) || (i == 10000));
}
s.put_CalcVisiblePoints(false);

No error on xcb_grab_key but event loop not catching (Global Hotkey)

I am trying to set up a global hotkey on Linux.
I had initially used x11 (libX11.so) however I had to do this from a thread. I tried it but the XPendingEvent and XNextEvent would eventually crash the app.
So I switched to xcb (libxcb.so.1). There is no errors, I even check with xcb_request_check however the event loop is not picking anything up. As soon as I start the loop, I get only one event which looks like this:
{
response_type: 0,
pad0: 10,
sequence: 2,
pad: [620, 2162688, 0, 0, 0, 0, 0],
full_sequence: 2
}
Here is my code, I actually do this in js-ctypes, but I cut down all the stuff to just show simple agnostic as possible code:
conn = xcb_connect(null, null);
keysyms = xcb_key_symbols_alloc(conn);
keycodesPtr = xcb_key_symbols_get_keycode(keysyms, XK_Space);
setup = xcb_get_setup(conn);
screens = xcb_setup_roots_iterator(setup);
screensCnt = screens.rem;
for (var i=0; i<screensCnt; i++) {
rez_grab = xcb_grab_key(conn, 1, screens.data.root, XCB_MOD_MASK_ANY, keycodesPtr[0], XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
rez_err = xcb_request_check(conn, rez_grab);
// rez_err is null
xcb_screen_next(&screens);
}
xcb_flush(conn);
// start event loop
while (true) {
ev = xcb_poll_for_event(conn);
console.log(ev);
if (ev != null) {
free(ev);
}
Sleep(50);
}
console.log(ev) gives me what I posted above earlier, response_type of 0 and then forever after that ev is just null.
Does anyone know what's up? rez_grab as a raw string is xcb_void_cookie_t(2)
Thanks much
Figured it out at long last!! Ah figured this one out! I was using XCB_MOD_MASK_ANY and this constant works on Debian but not on Ubuntu, which is what I was using to test. I switched that up to use num lock, caps lock etc and now it works! :)
ostypes.API('xcb_grab_key')(conn, 1, screens.data.contents.root, ostypes.CONST.XCB_MOD_MASK_LOCK, keycodesArr[j], ostypes.CONST.XCB_GRAB_MODE_ASYNC, ostypes.CONST.XCB_GRAB_MODE_ASYNC); // caps lock
ostypes.API('xcb_grab_key')(conn, 1, screens.data.contents.root, ostypes.CONST.XCB_MOD_MASK_2, keycodesArr[j], ostypes.CONST.XCB_GRAB_MODE_ASYNC, ostypes.CONST.XCB_GRAB_MODE_ASYNC); // num lock
ostypes.API('xcb_grab_key')(conn, 1, screens.data.contents.root, ostypes.CONST.XCB_MOD_MASK_LOCK | ostypes.CONST.XCB_MOD_MASK_2, keycodesArr[j], ostypes.CONST.XCB_GRAB_MODE_ASYNC, ostypes.CONST.XCB_GRAB_MODE_ASYNC); // caps lock AND num lock
that was very very crazy i had no idea the XCB_MOD_MASK_ANY constant didnt work on Ubuntu -
var rez_grab = ostypes.API('xcb_grab_key')(conn, 1, screens.data.contents.root, ostypes.CONST.XCB_MOD_MASK_ANY, keycodesArr[j], ostypes.CONST.XCB_GRAB_MODE_ASYNC, ostypes.CONST.XCB_GRAB_MODE_ASYNC);
I also tried #n.m's code. On ubuntu it didnt work, but worked on debian -
#include <xcb/xcb.h>
#define XK_LATIN1
#include <xcb/xcb_keysyms.h>
#include <X11/keysymdef.h>
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
xcb_connection_t *conn;
conn = xcb_connect (NULL, NULL);
xcb_key_symbols_t * keysyms = xcb_key_symbols_alloc(conn);
xcb_keycode_t * keycodesPtr = xcb_key_symbols_get_keycode(keysyms, XK_space);
const xcb_setup_t* setup = xcb_get_setup(conn);
xcb_screen_iterator_t screens = xcb_setup_roots_iterator(setup);
int screensCnt = screens.rem;
for (int i=0; i<screensCnt; i++) {
xcb_void_cookie_t rez_grab = xcb_grab_key(conn, 1, screens.data->root, XCB_MOD_MASK_ANY, keycodesPtr[0], XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
const static uint32_t values[] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS };
xcb_change_window_attributes (conn, screens.data->root, XCB_CW_EVENT_MASK, values);
xcb_screen_next(&screens);
}
xcb_flush(conn);
// start event loop
while (1) {
xcb_generic_event_t *ev = xcb_wait_for_event(conn);
if (ev && ((ev->response_type & ~0x80) == XCB_KEY_PRESS))
{
xcb_key_press_event_t *kp = (xcb_key_press_event_t *)ev;
printf ("Got key press %d\n", (int)kp->event);
}
if (ev != NULL) {
free(ev);
}
}
return 0;
}

C++ ProgressBar and function (multithreading)

I have a program (C++ Form App, Viusal Studio 2013) that pressing a particular key on form launches the function that run about 20 seconds. I would like to set one progress bar that will indicate the state of the function. I know that the execution of the functions and UI have to put in different thred just do not know how to do it.. Can someone help?? Thanks!!
This is a function call:
private: System::Void BzapocniObradu_Click(System::Object^ sender, System::EventArgs^ e)
{
...
String^ a = JPGtoPPM(picPath[i]);
...
}
First you need to include this namespace:
using namespace System::Drawing;
Then do something like that:
void PintarPictureBox(String^ strTexto,int ancho, PictureBox ^pictureBox1,Color Color1, Color Color2){
using namespace System::Drawing::Drawing2D;
Bitmap^ bmp = gcnew Bitmap(pictureBox1->Width, pictureBox1->Height);
Graphics^ g = Graphics::FromImage(bmp);
if(ancho <= 0)
pictureBox1->Image = nullptr;
else
{
Point point1 = Point(0,10);
Point point2 = Point(ancho,10);
LinearGradientBrush^ linGrBrush = gcnew LinearGradientBrush(
Point(0,10),
Point(ancho,10),
Color1, Color2);
Pen^ pen = gcnew Pen(linGrBrush);
g->FillRectangle(linGrBrush, 0, 0, ancho, pictureBox1->Height);
}
System::Drawing::Font^ drawFont = gcnew System::Drawing::Font( "Arial",8 );
SolidBrush^ drawBrush = gcnew SolidBrush( Color::White );
g->DrawString(strTexto,
drawFont, drawBrush,
0,0);
pictureBox1->Image = bmp;
delete g;
}
After that , to use it:
//in this case img_HP is my PictureBox and iHPCurrent/iHPMax are variables of stathook.
PintarPictureBox(iHPCurrent.ToString() + " / " + iHPMax.ToString(),(img_HP->Width*iHPCurrent)/iHPMax,
img_HP,Color::FromArgb(150,0,0),Color::Red);
Source: https://ccplz.net/threads/tutorial-how-to-make-a-cute-progress-bar-cli-c.26895/
Off course this is just an example how to implement a progress bar, you can modify it to your needs.
I hope that support you question.

applicationData.current.localFolder.CreateFileQueryWithOptions(queryOptions); don't work

I excerpt from windows 8.1 sample of StorageDataSource and GetVirtualizedFilesVector sample a piece of code in my project can run successfully, but I changed to this: From ApplicationData.current.localFolder the deposit into my pictures do not show up success
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var queryOptions = new QueryOptions();
queryOptions.FolderDepth = FolderDepth.Deep;
queryOptions.IndexerOption = IndexerOption.UseIndexerWhenAvailable;
queryOptions.SortOrder.Clear();
var sortEntry = new SortEntry();
sortEntry.PropertyName = "System.FileName";
sortEntry.AscendingOrder = true;
queryOptions.SortOrder.Add(sortEntry);
//var fileQuery = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions);
var fileQuery = ApplicationData.Current.LocalFolder.CreateFileQueryWithOptions(queryOptions);
const uint size = 400; // default size for PicturesView mode
var fileInformationFactory = new FileInformationFactory(fileQuery, ThumbnailMode.PicturesView, size, ThumbnailOptions.UseCurrentScale, true);
itemsViewSource.Source = fileInformationFactory.GetVirtualizedFilesVector();
}
Commented that the original sample code, comments, following the line of code that I want to be able to run.
thanks a lot!
Do you have accessright for picture library?
To do the programatic access like your code, The app should have it.
You can on/off it from Package.appxmanifest.

Resources