This problem is hard to describe and didn't find any hits on google.
i have a WndProc,
in the callback the proper functions Like WM_CREATE. (using VS2015, C++)
inside i'm using around 75 CreateWindowW functions to create buttons.
i had the problem before that just some window creations didn't show up.
assumed that i made a mistake my self, and found that if i just create the window twice is still shows so out of the 75 buttons there is only 70 that are real
it was always consistent which one didn't show up, until today where 2 of them swapped the fake one started to show and the one that i needed was gone (between 2 Debug sesions), its a very easy fix to just make the fake one work and show it in the right location but it doesn't feel right
Does anybody ever has something like this? or where should i start with looking it to this?
im using the show and hide functions with this button, but that is not the case with the previous ones
ShowWindow(savebutton, SW_HIDE);
ShowWindow(cancelbutton, SW_HIDE);
ShowWindow(editbutton1, SW_SHOW);
savebutton = CreateWindowW(L"BUTTON", L"Save", WS_CHILD, 952, 103, 50, 19, hWnd, (HMENU)ID_LSAVE, 0, 0);
cancelbutton = CreateWindowW(L"BUTTON", L"Cancel", WS_CHILD, 902, 103, 50, 19, hWnd, (HMENU)ID_LCANCEL, 0, 0);
editbutton = CreateWindowW(L"BUTTON", L"Edit", WS_VISIBLE | WS_CHILD, 1002, 103, 50, 19, hWnd, (HMENU)ID_LEDIT, 0, 0);
editbutton1 = CreateWindowW(L"BUTTON", L"Edit", WS_VISIBLE | WS_CHILD, 902, 103, 50, 19, hWnd, (HMENU)ID_LEDIT, 0, 0);
Related
I have a very strange issue where a chart (SwiftChart) is not being displayed (is not visible/rendered) when the project is built and run.
Some background:
XCode 8 (project was originally and XCode 7 project)
Objective C project/ViewControllers
A swift file to render the chart (have tried calling this from viewDidLoad & viewDidLayoutSubviews)
Storyboard containing all ui elements
Using CocoaPods
The 'print' code you see in Swift outputs 'null'
The UIView where the chart is to be rendered exists within the storyboard and is setup as follows
The code being called is:
let chart = Chart()
print(chart.window?.frame.width)
print(chart.window?.frame.height)
let data = [(x: 0.0, y: 0), (x: 3, y: 2.5), (x: 4, y: 2), (x: 5, y: 2.3), (x: 7, y: 3), (x: 8, y: 2.2), (x: 9, y: 2.5)]
let series = ChartSeries(data: data)
series.area = true
chart.xLabels = [0, 3, 6, 9, 12, 15, 18, 21, 24]
chart.xLabelsFormatter = { String(Int(round($1))) + "h" }
chart.add(series)
Visually I see nothing. I'm struggling to figure out where the problem might be so any pointers greatly appreciated
You uave to initialize it with a frame when creating it programmatically since it's a UIControl subclass. It appears their first code example is wrong but they explain it correctly in the next. All on-screen views need a frame at a minimum.
But if you already have a view of this class in your storyboard you need an outlet to point to it. Your first line of code creates a new one, so you're not talking to the one you set up, but an improperly created off-screen one.
So add an outlet and connect it to your view so you can talk to it.
My event handler is as follows:
procedure TfrmCanvasMethods.btnShapesClick(Sender: TObject);
begin
Canvas.Rectangle(40, 40, 400, 200);
Canvas.Rectangle(80, 80, 360, 160);
Canvas.Ellipse(150, 50, 290, 190);
Canvas.Ellipse(100, 100, 340, 140);
end;
I am using Mac OS X
You have to read fundamentals about graphic windowing systems. Be it Windows, MacOS or UNIX X Window.
Almost universally that is not the application who decides when, what and where to draw. It is Operating System that decides so and asks the application when to do it. All an application can do - is to invalidate some part of its window - that is to inform the OS that some part of the window is no more valid, and then wait until the OS would want that part repainted (maybe it would be never, if the invalidated window got minimized or covered by another window) and then - and only then - do the drawing.
So how can you do it?
Method 1: resources-savvy and close to real OS workflow.
You put a TPaintbox over your whole form.
http://docwiki.embarcadero.com/Libraries/Seattle/en/Vcl.ExtCtrls.TPaintBox
http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tpaintbox.html
You keep your rectangles and circles as non-visible records or classes inside your form's variables. When those figures are changed (example: you added yet another rectangle, or you increased some circle diameter) you call MyForm.MyPaintBox.Invalidate to inform the operating system that the image of that painboxt is no more valid. When OS would consider it is timely to refresh the image, it would call MyForm.MyPaintBox.OnPaint event and in that event you would make your calls like MyPaintBox.Canvas.Rectangle(40, 40, 400, 200);. Notice - you would repaint the paintbox's canvas, not the form's one!
procedure TfrmCanvasMethods.btnShapesClick(Sender: TObject);
begin
MyPaintBox.Invalidate();
end;
procedure TfrmCanvasMethods.MyPaintBoxPaint(Sender: TObject);
var Canvas: TCanvas;
begin
Canvas := MyPaintbox.Canvas;
Canvas.Rectangle(40, 40, 400, 200);
Canvas.Rectangle(80, 80, 360, 160);
Canvas.Ellipse(150, 50, 290, 190);
Canvas.Ellipse(100, 100, 340, 140);
end;
Method 2: lazy and resources-bloating
You put a TImage over your whole form.
http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/timage.html
That image would have the implicit bitmap having any picture you would like. More so, it would track your drawing of that picture and would automagically call Invalidate and would automagically handle OS's repaint requests.
procedure TfrmCanvasMethods.btnShapesClick(Sender: TObject);
var Canvas: TCanvas;
begin
MyImage.Picture.Bitmap.SetSize( MyImage.ClientWidth, MyImage.ClientHeight );
Canvas := MyImage.Picture.Bitmap.Canvas;
Canvas.Rectangle(40, 40, 400, 200);
Canvas.Rectangle(80, 80, 360, 160);
Canvas.Ellipse(150, 50, 290, 190);
Canvas.Ellipse(100, 100, 340, 140);
end;
The price however would be that you would allocate maybe as much as few megabytes of memory for nothing more than keeping your picture for those relatively rare cases when OS would need to refresh the picture of your form.
This is a as far as I got. Im trying to make a Phenaniskope
bg = new BackgroundLayer
backgroundColor: "pink"
frame = new Layer
width: 250
height: 250
image: "images/phenakistoscope.png"
frame.center()
Utils.interval 1, ->
cycler = Utils.cycle([10, 20, 30, 40, 50])
frame.rotation = cycler()
I made some quick changes and explained in the comments:
http://share.framerjs.com/kr6mvm4y8xcl/
Basically, you left the cycler inside the interval, so it was being "reset" every time, thus you would stop at rotation 10.
Hope this helps!
I want to create a layout of 2 blocks on a page, each with 3 columns. I am currently using example 10 of the documentation and the setEqualColumns() method.
How can I fix a maximum height?
The result I want to achieve:
you must use SetAutoPageBreak() and resetColumns() functions (more details here). Be careful, if your text is longer than the allowed space, the rest of the text will be written on the next page.
For example :
//Set the distance from the bottom the first block must stop : 130
$pdf->SetAutoPageBreak(true, 130);
//Write the first block : 3 columns, width 50
$pdf->setEqualColumns(3, 50);
$pdf->writeHTML($content_1);
//reset columns
$pdf->resetColumns();
//reset the X position and the page break
$margins = $pdf->getMargins();
$pdf->setX($margins['left']);
$pdf->SetAutoPageBreak(true, $margins['bottom']);
//write the chapter title (like in the TCPDF example 10)
$pdf->SetFillColor(200, 220, 255);
$pdf->Cell(180, 6, 'Chapter 2', 0, 1, '', 1);
//write the second block
$pdf->setEqualColumns(3, 50);
$pdf->writeHTML($content_2);
i'm hoping that this quick description and image will ring a bell with someone who has had a similar issue and therefore a suggestion/fix.
i have a column graph that i am adding data to dynamically (via jQuery parsing an XML file).
for some reason, after the data is added, the alignment of the different series gets a little off. the issue fixes itself after i toggle one of the series by being visible/invisible (by clicking the series in the legend).
when i add the data via hardcoding the numbers, just to ensure it works, it works great.
here is the image:
the yellow series is the last series added to the chart, the red and purple series line up ok after toggling the visibility of one of the 5 series.
any help would be greatly appreciated!
UPDATE with info on the data:
i have 5 series of data and 10 x-axis categories
i am building a multidimensional array of data as i parse the XML file
the array length is 5, with each of those 5 index's containing an array of length 10
this is what the array looks like after it has been populated with data:
index#: 0 value: 0,0,0,0,0,0,0,0,0,0
index#: 1 value: 180,210,0,0,0,0,0,0,180,210
index#: 2 value: 22,4,0,0,0,0,0,0,22,4
index#: 3 value: 0,0,0,0,0,0,0,0,0,0
index#: 4 value: 200,30,0,0,0,0,0,0,4,0
i am adding the data to the chart with the following JS code:
for (var c_ary_bs = 0; c_ary_bs < ary_bs_schedule_orig.length; c_ary_bs++) {
chart.series[c_ary_bs].setData(ary_bs_schedule_orig[c_ary_bs]);
}
hopefully that will help, thank you!
UPDATE 2, some more info
i've hard coded the data being added to the array, to help pinpoint the issue:
chart.series[0].setData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
chart.series[1].setData([180, 210, 0, 0, 0, 0, 0, 0, 180, 210]);
chart.series[2].setData([22, 4, 0, 0, 0, 0, 0, 0, 22, 4]);
chart.series[3].setData([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
chart.series[4].setData([200, 30, 0, 0, 0, 0, 0, 0, 4, 0]);
alert('done')
when the alert fires, the graph columns are aligned properly, after I click "ok" to dismiss the alert, the alignment issue happens, as the previous image depicts.
I found an imperfect fix:
-setting the marginLeft of the chart to 70 alleviates the issue with the columns not aligning
-for some reason the y-axis title text is displaying over the y-axis ticks, so i am using the following to make it visible:
yAxis: {
title: {
x:-20,
text: 'Schedule Days'
}
}
(note the x: -20)
Whats's odd is that when I toggle one of the series (by clicking it in the legend) the yAxis title text reverts to where it should be (which is now 20px off because of the above fix).
The perfect fix would put the yAxis text where it is after I toggle one of the series, but at least this way it is now visible regardless of whether or not the user toggles the series.