« first day (1133 days earlier)      last day (3832 days later) » 

3:00 AM
there's a couple approaches to it, I use the ImageBase one, you can also use GetModuleHandle.
 
@DeadMG so where does the user data go in this param struct thing?
 
@DeadMG realisticly?
 
@melak47 You don't fill out the struct, Windows does. But you pass the value as the last parameter to CreateWindowEx.
@Pawnguy7 I mean, the practicalities of passing the HINSTANCE around fucking everywhere, it's not something you want infesting all your top-level APIs
 
@melak47 You must allocate space first in your class.
But I guess you already know that.
 
@MarkGarcia but it's supposed to ship with one ptr sized piece of space by default
 
3:02 AM
@melak47 I'm uneasy with that one. I always make sure I allocate enough space.
WNDCLASSEX::cbWndExtra
 
= 0;
 
= sizeof(this); or LONG_PTR.
 
but then you have to use DWLP_USER, right?
what would be the point of having GWLP_USERDATA then, if it didn't exist :p
 
user3010322
Nope.
 
user3010322
hwnd = CreateWindowExW( WS_EX_ACCEPTFILES | WS_EX_TRANSPARENT,
			idapi, titleapi,
			WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
			fullscreen ? 0 : x, fullscreen ? 0 : y,
			wr.right - wr.left,
			wr.bottom - wr.top,
			null, null, instancehandle, this );
 
user3010322
3:05 AM
^ last parameter to CREATEWINDOWEX is this
 
user3010322
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
		wc.lpfnWndProc = detail::SWndProc;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = sizeof( this );
 
user3010322
set the cbWndExtra to the size of a "this" pointer.
 
user3010322
After that, you're all set.
 
then when you receive WM_CREATE, cast the LPARAM to a CREATESTRUCT* and access the lpCreateParams member
 
@DeadMG Things need it besides CreateWindow?
 
user3010322
3:06 AM
@DeadMG Is it only for WM_CREATE, though?
 
@Pawnguy7 A few things, but that's not important. You just want to keep your top level APIs as platform-independent as possible.
@ThePhD No fucking idea.
 
user3010322
If so, it's still not that useful then in the end? Unless WM_CREATE is the absolute first message your window will ever receive.
 
@melak47 Hm. So you're depending on GWL_USERDATA always being a pointer.
Or at least having the size of a pointer.
 
@ThePhD It is.
 
@ThePhD You would have to use GetWindowLongPtrW(hwnd, GWLP_USERDATA) for the rest.
If you've called SetWindowLongPtrW(hwnd, GWLP_USERDATA, ptr);.
 
user3010322
3:08 AM
@DeadMG Okay, so a way to do that then is to get the very first message of WM_CREATE, get the this point out of the CREATESTRUCT*, and then do a SetWindowLongPtrW( hWnd, GWLP_USER_DATA ); which will take the HWND already created by windows that is passed to that first WM_CREATE (through the WndProc).
 
user3010322
After that, the entire process becomes entirely automatic.
 
user3010322
No need to check for null handles or anything on a list of creating window classes, it'll be entirely self-contained
 
user3010322
At least, I hope hWND is populated with the correct and valid window reference.
 
user3010322
If it's not, then fuck me. :D
 
@ThePhD It's more or less guaranteed that hwnd passed to wndproc is valid.
 
user3010322
3:12 AM
Then this technique should work just fine~
 
lol. "more or less guaranteed" typical of WinAPI. :)
 
On a side note, I wish = 0 was pure for pure virtual functions. Eg. virtual void func() pure;
 
user3010322
Finally, I can get rid of my std::vector<Win32Window*> sitting in the detail:: namespace
 
user3010322
@Jefffrey I think there's a draft of that somewhere?
 
user3010322
But I think they voted it down because "new keywords"
 
3:12 AM
@ThePhD ew :o
 
user3010322
@melak47 Eww indeed.
 
@Jefffrey #define pure = 0. Don't know if that works. :P
 
user3010322
But there was no other way to know about which windows were being created and not created.
 
@MarkGarcia I'm not that desperate ;)
 
@Jefffrey It was going to be but it was decided that adding a new keyword would have been useless.
 
3:14 AM
Wouldn't you guys prefer pure over =0?
 
@ThePhD if CreateWindowEx failed, it wasn't created :D
 
no
 
user3010322
@melak47 WM_CREATE can't be a failure?
 
pure virtual functions don't even make sense
they're abstract
 
@ThePhD idk, I don't check for WM_CREATE lol
 
3:15 AM
@Jefffrey I want three generation types
 
@Rapptz What do you mean by abstract?
 
it's called an abstract function
C++ is the only one that calls it pure
In programming languages, an abstract type is a type in a nominative type system which cannot be instantiated directly. Abstract types are also known as existential types. An abstract type may provide no implementation, or an incomplete implementation. Often, abstract types will have one or more implementations provided separately, for example, in the form of concrete subclasses which can be instantiated. It may include abstract methods or abstract properties that are shared by its subtypes. The object oriented form of abstract types are known as abstract base classes or simply abstract...
 
C++ pure virtual functions can have an implementation though. They are not abstract.
 
Not if you do = 0?
 
Yes if you do = 0.
 
3:17 AM
Oh.
What difference is there between them?
 
Prime example is Scott Meyer's pure virtual destructor with a definition.
 
^
 
@Jefffrey Irrelevant
 
user3010322
@melak47 @Rapptz @MarkGarcia @DeadMG Sexy Window Proc
 
@Rapptz Yeah, I thought you meant that they should have been empty.
 
3:20 AM
@DeadMG @ThePhD I still get messages that aren't WM_CREATE where the this ptr isn't stored in the user data yet :/
 
user3010322
@melak47 Before WM_CREATE?
 
yes
3 messages before WM_CREATE
 
user3010322
What are they?
 
idk
 
user3010322
:|
 
user3010322
3:21 AM
You got a fancy debugger, man
 
user3010322
MANG.
 
yes and my fancy debugger says the messages are 36, 129, 131 :)
 
Spy++ is indispensable.
 
36 should be WM_GETMINMAXINFO, 129 is WM_NCCREATE, 131 is WM_NCCALCSIZE
 
user3010322
3:23 AM
I guess intercepting those isn't of top priority?
 
> bash: line 7: 8352 Killed ./a.out
wat Coliru
 
user3010322
It's still pre-messages that you miss, though
 
user3010322
@melak47 Is the CREATESTRUCT* cast worth anything for those early messages?
 
@ThePhD nope
nullptr :)
 
user3010322
Damn.
 
3:24 AM
SetWindowLongPtrW( hwnd, GWLP_USERDATA, reinterpret_cast<LONG>( creationparams.lpCreateParams ) ); why are you doing this in the WndProc? :E
 
user3010322
I want ALL THE MESSAGES.
 
user3010322
ALL OF THEM. D:<
 
Suggestions for third?
 
@ThePhD you're casting your pointer to a LONG? LONG is just long, which is 32 bit :E
 
3:24 AM
@Pawnguy7 why are you posting multiple large images in chat?
 
user3010322
@melak47 Are you suuuure?
 
typedef long LONG;
 
user3010322
What about in 64-bit?
 
@ThePhD yes
 
I am in 64 bit.
 
3:25 AM
@ThePhD still 32 bits
 
user3010322
Oh.
 
user3010322
Well then. Shrug.
 
Btw Mooing
 
you want to cast to LongPtr or something
 
Your regex is so simple that it's depressing for it to be slow.
Have you considered reporting it?
 
3:26 AM
@melak47 Or just a normal pointer type.
 
@MarkGarcia yeah :p
 
@Rapptz I thought about it. Not sure if that's the same as "considering" it.
 
@ThePhD but yeah, after that I don't seem to be missing any messages.
 
user3010322
@melak47 I want every single message. From the moment it reaches WndProc. And I want it piped hot and fresh to my application.
 
@Rapptz yeah, regexes with no backtraces nor *+| should be optimized better.
 
user3010322
3:27 AM
Windows I WILL HAVE YOUR SECRETS.
 
@ThePhD GETMINMAXINFO is irrelevant anyway, it'll be sent again when you resize
 
user3010322
@melak47 But what about NCCREATE and NCCALCSIZE ?
 
user3010322
Hmmmmmmmm?
 
user3010322
What about thooose?
 
haven't had a problem receivingWM_NCCALCSIZE, dunno about NCCREATE
 
user3010322
3:29 AM
No, I mean
 
user3010322
How do you get those to the window that's being created?
 
@Rapptz it's hard to make the argument that regexes containing ? should be optimized better.
 
@ThePhD well, I guess I miss that first one
 
How about the fact that every other regex library isn't slow ?_?
This is an incredibly basic regex.
 
@Rapptz did you profile them?
 
3:30 AM
but it's not been a problem, there seem to be plenty more of them coming when you need them
 
@MooingDuck I know for a fact Python's PCREs aren't very slow (because my regex are quite complex)
I could profile it though.
I know .NET isn't so bad unless you take into consideration unicode (just like Python)
 
@Rapptz should be relatively easy
 
@Jefffrey Oh. Strange. Any idea on the generations?
 
user3010322
@MooingDuck Psst, hey, I got a question for ya based on design and stuff.
 
@Pawnguy7 The images?
 
3:32 AM
@ThePhD answer: don't do it that way.
 
@Jefffrey yes. I want a third type.
 
user3010322
@MooingDuck You didn't even see the question. :c
 
user3010322
That's horribly biased.
 
@Pawnguy7 Without walls? :3
 
ok post the question
 
user3010322
3:33 AM
48 mins ago, by ThePhD
Problem: http://coliru.stacked-crooked.com/a/25db3b55088516cd
Solution 1, Event Caller: http://coliru.stacked-crooked.com/a/362e12f7ef23a9e5
Solution 2, Template Friend: http://coliru.stacked-crooked.com/a/0fcabbd33921d2a5

@R.MartinhoFernandes @Xeo which would you prefer? :O
 
and then I can link to my already posted answer :D
 
@MooingDuck k gimme a minute
 
user3010322
Aww... :c
 
user3010322
Oh, I forgot Rapptz's solution
 
@Jefffrey Completely blank?
 
3:34 AM
@ThePhD it tends to be the answer to 99% of the questions by people who know C++ in here, regardless of the asker
 
user3010322
Uh. Now I gotta find a link to it...
 
@ThePhD Make it private
 
@Borgleader add_handler I think.
 
private handling, IYKWIM
 
user3010322
Solution 3, Make Private and Add Functions to Class: coliru.stacked-crooked.com/a/c423fca4772930e5
 
3:35 AM
@Pawnguy7 Concentric rectangle walls with just 1 or 2 holes (to let the snake pass through one another).
 
@Borgleader Oh. And TIL that acronym. :)
 
@ThePhD I see a std::list, that's probably not optimal
ah, nevermind
 
@Jefffrey circles?
 
@Pawnguy7 Circles in a grid could be tough
 
3:39 AM
@ThePhD something is horribly wierd with that first one.
 
@Jefffrey simple radius, I guess.
Might look more like an octagon.
I am not sure what you meant, then.
Or do you mean.
The basic walled one.
With holes in the walls?
 
user3010322
@MooingDuck std::list's iterators persist no matter what happens to the list, so they actually act as the perfect tokens for an Event implementation (that needs tokens to identify functions and such).
 
     return Add( std::addressof( object ) );
		Token Add( T* object ) { //why this parameter?
			TCallback c; //why this local?
			return Add( std::move( c ) ); //why moving?
		}
 
user3010322
Ooh, that may be a massive typo I didn't pick up on. o.0
 
there's a lot of code here that does nothing useful
 
user3010322
3:42 AM
I think at the time I was implementing a lazy_bind, but don't mind me.
 
user3010322
Pretend the Event implementation isn't busted and incomplete. >_>
 
@Pawnguy7 Rectangles of walls. Like in the first one (the number 2) there's that border of walls, you copy that rectangle and you make is 3-4 blocks smaller in both height and width and you destroy 2 or 3 of its blocks (and continue like this as much as you want).
 
@ThePhD makes it hard to evaluate your code
 
user3010322
Sorry. I'll repost with the proper code in place...
 
also, doesn't boost already have an event thing? (yes)
 
3:45 AM
@ThePhD - looked at it - old school thinking says make Arf a friend of event and make constuctor private - what am i missing?
 
user3010322
@MooingDuck It does, I'm just picking my own brain here.
 
user3010322
@GlennTeitelbaum That's good, but Arf isn't the only class that'll have an Event type, so you can't just make Arf explicitly the only friend (that's what Solution #2 solves).
 
    value = (rand()%17+1)*1000 + rand()%1000;
wot
 
user3010322
templated friends were always part of C++? Or just part of C++11 ?
 
C++11 I think
 
3:48 AM
@Rapptz holy magic constants batman
 
user3010322
Welp. Guess I'm never going back. :D
 
@Rapptz VS had them before that. Not sure if that was standard though
 
that's Mooing's profiling code but I don't know how to convert that
 
@Rapptz oh, that picks a random... wait, as I thought of how to describe it I realize it can be very easily simplified...
 
is this "I just want 4 random digits"?
 
3:49 AM
it picks a random number between 1000 and 19999 :(
 
user3010322
Lol.
 
@Rapptz four to five random digits with equal frequency
 
@MooingDuck Nothing in the code says something like that. :P
 
@MarkGarcia yeah :(
 
@ThePhD - ah - I answered your question but you meant it generically
 
3:50 AM
I typed first version in a webpage and it was lost. Second version had no comments :/
 
@MooingDuck Okay. random.randrange(1000, 19999) it is :P
 
@Rapptz yeah
 
@Rapptz Why are you converting his code?
 
profiling Python's PCRE
 
@Borgleader measure regex performance penalty in python
 
user3010322
3:51 AM
@GlennTeitelbaum Yeah, that's what I meant.
 
@ThePhD Invoke shouldn't take rvalues (for same reasons bind doesn't take rvalues)
 
@ThePhD - btw when I first looked at Solution1 - I saw that you had commented out the bad one and thought wow - thats a trivial solution - now it wont compile
 
user3010322
@GlennTeitelbaum Haha, yeah. x3 I actually wanted it to show a result, so I had to comment it out, but if you comment it back in it fails to compile, which means the goal was achieved.
 
> error C2280: 'std::pair<dxdr::math::float2,dxdr::math::float2>::pair(const std::pair<dxdr::math::float2,dxdr::math::float2> &)' : attempting to reference a deleted function
I'd love to know WHICH deleted function :(
 
@melak47 check the output window
 
user3010322
3:55 AM
The copy constructor.
 
that's where I am :(
 
@melak47 also that's the copy constructor
 
user3010322
Apparently
 
so...std::pair has a deleted copy ctor?
 
pair<T>::pair(const pair<T>&)
@melak47 if the types aren't copiable, then yes
 
3:55 AM
the types are copyable ._.
 
user3010322
@melak47 Depends on the ttypes, I think
 
user3010322
^ What @MooingDuck said. :D
 
@melak47 apperently not
 
but, vec(const vec<T, 2>& copy) = default; :/
 
@ThePhD - so what are you looking to do at a high level?
 
3:57 AM
(using float2 = vec<float,2>;)
 
make a const float2 and then copy it, and see if that compiles.
 
does regex::match_default match all or something?
 
user3010322
@GlennTeitelbaum The goal was kind of to emulate C# events. But then, the design issue came up (as shown in the int main() function of the problem code): should we disallow a class outside the Event's scope (e.g, outside of Arf) to call the Event's invoke function and make the entire Event callback trigger? Or should ONLY the class/scope that the Event is declared in have that right?
 
@Rapptz it's the default regex behavior. read the docs, the ohter options are confusing
 
user3010322
I decided that if we DID say "only the owning class", then the question was "how do you actually make that a reality?"
 
3:59 AM
@MooingDuck excluded the files producing that error to test that...and now I get
> error C2280: 'std::pair<std::string,std::string>::pair(const std::pair<std::string,std::string> &)' : attempting to reference a deleted function
 

« first day (1133 days earlier)      last day (3832 days later) »