Re: Window created with Windows API is not visible

2022-06-18 Thread Adam Ruppe via Digitalmars-d-learn

On Saturday, 18 June 2022 at 23:00:36 UTC, solidstate1991 wrote:

This is going to be a long match.


you might consider using another exisitng lib. my simpledisplay.d 
does all this and much more for example


Re: Window created with Windows API is not visible

2022-06-18 Thread rikki cattermole via Digitalmars-d-learn



A white content area, means that you didn't draw something.

As long as the border ext. is showing up, you're ok.


Re: Window created with Windows API is not visible

2022-06-18 Thread solidstate1991 via Digitalmars-d-learn

On Saturday, 18 June 2022 at 22:46:45 UTC, rikki cattermole wrote:

registeredClass.style = 32_769;

Don't use an integer like that, stick with bit wise ors.



LPCWSTR classname = toUTF16z(name);

GC owned memory, that could result in surprises.



const LPWSTR windowname = toUTF16z(title);

Ditto



I'm not sure your window callback procedure is right.

For instance you are not calling DefWindowProc, and you are not 
handling WM_PAINT in any form.




But one other thing, your approach to the event loop is going 
to come back to bite you at some point. Windows is based around 
a push event loop model, not a pull like other system Windowing 
libraries (such as X11). It can get recursive. I learned this 
one the hard way.


Well, it seems like my window callback wasn't right. Now at least 
I get whiteness instead of nothing. This is going to be a long 
match.


Re: Window created with Windows API is not visible

2022-06-18 Thread rikki cattermole via Digitalmars-d-learn

registeredClass.style = 32_769;

Don't use an integer like that, stick with bit wise ors.



LPCWSTR classname = toUTF16z(name);

GC owned memory, that could result in surprises.



const LPWSTR windowname = toUTF16z(title);

Ditto



I'm not sure your window callback procedure is right.

For instance you are not calling DefWindowProc, and you are not handling 
WM_PAINT in any form.




But one other thing, your approach to the event loop is going to come 
back to bite you at some point. Windows is based around a push event 
loop model, not a pull like other system Windowing libraries (such as 
X11). It can get recursive. I learned this one the hard way.


Re: Window created with Windows API is not visible

2022-06-18 Thread solidstate1991 via Digitalmars-d-learn

On Saturday, 18 June 2022 at 21:33:31 UTC, Vinod K Chandran wrote:


It seems that you are created a layered window. So chances are 
there to it become translucent.


Did not set the flags for the layered window style, so I don't 
know. Might be an event processing error, since in Windows it's a 
mess.


Re: Window created with Windows API is not visible

2022-06-18 Thread Vinod K Chandran via Digitalmars-d-learn

On Saturday, 18 June 2022 at 21:03:23 UTC, solidstate1991 wrote:





It seems that you are created a layered window. So chances are 
there to it become translucent.





Window created with Windows API is not visible

2022-06-18 Thread solidstate1991 via Digitalmars-d-learn

Code:

https://github.com/ZILtoid1991/iota/blob/main/inputtest/app.d

https://github.com/ZILtoid1991/iota/blob/main/source/iota/window/base.d#L104

Second one contains the constructor that should make the window 
without any issues.


When I try to create a window for testing purposes, I get nothing 
besides of an icon on the taskbar. Once I was able to get a quite 
broken window to show up, then it doesn't showed up anymore. 
Calling the API function `IsWindowVisible` returns true.


Re: can you initialize a array of POD structs?

2022-06-18 Thread Chris Katko via Digitalmars-d-learn

On Saturday, 18 June 2022 at 17:52:16 UTC, Adam D Ruppe wrote:

On Saturday, 18 June 2022 at 17:37:44 UTC, Chris Katko wrote:

D
struct pair { float x, y;}

pair p[] = [[0, 0], [255, 255], [25,-25]]; //nope



An array of pair is `pair[]`, keep the brackets with the type.

Then a struct literal is either:

pair(0, 0) // using constructor syntax

or in some select contexts (including this one):

{0, 0} // using named literal syntax


Therefore:

pair[] p = [{0, 0}, {255, 255}, {25,-25}];

compiles here.


Thanks!!

One extra caveat for anyone who googles this. You can't use {0, 
0} notation if the struct has constructors. Which make sense 
since you don't want people accidentally bypassing a constructor 
if it exists.


Re: can you initialize a array of POD structs?

2022-06-18 Thread Adam D Ruppe via Digitalmars-d-learn

On Saturday, 18 June 2022 at 17:37:44 UTC, Chris Katko wrote:

D
struct pair { float x, y;}

pair p[] = [[0, 0], [255, 255], [25,-25]]; //nope



An array of pair is `pair[]`, keep the brackets with the type.

Then a struct literal is either:

pair(0, 0) // using constructor syntax

or in some select contexts (including this one):

{0, 0} // using named literal syntax


Therefore:

pair[] p = [{0, 0}, {255, 255}, {25,-25}];

compiles here.


Re: multidim array with enum

2022-06-18 Thread Adam D Ruppe via Digitalmars-d-learn

On Saturday, 18 June 2022 at 17:19:24 UTC, Chris Katko wrote:
I'm having difficulty figuring out exactly what signature D is 
expecting.


BITMAP*[2][DIR] bmps;


I'm actually not sure if that [DIR] is an associative array or 
DIR's base type or a static array of DIR's size.


I *think* it is an assoc array... let's test it using the `in` 
operator:


auto a = DIR.UP in bmps;

That compiled. So this must be an associative array!


Try this instead:

BITMAP*[2][DIR.max] bmps;


That's a static array of directions and I think that's what you 
intended and the other things should work as you want too with 
this.


can you initialize a array of POD structs?

2022-06-18 Thread Chris Katko via Digitalmars-d-learn

D
struct pair { float x, y;}

pair p[] = [[0, 0], [255, 255], [25,-25]]; //nope



multidim array with enum

2022-06-18 Thread Chris Katko via Digitalmars-d-learn
I'm having difficulty figuring out exactly what signature D is 
expecting.


D
enum DIR
{
UP = 0,
DOWN,
LEFT,
RIGHT,  
UPLEFT,
UPRIGHT,
DOWNRIGHT,
DOWNLEFT,
}

BITMAP*[2][DIR] bmps;

// ...

bmps[DIR.UP][0] = nope.
bmps[DIR.UP][0] = new BITMAP *; // nope
bmps[DIR.UP][0] = new BITMAP; // nope
bmps[DIR.UP] = new BITMAP*[2]; // compiles. runtime range 
violation.




I swear this all worked fine when it was just:
D
bmps[DIR] bmps;