Re: winapi, dll

2020-10-15 Thread John Chapman via Digitalmars-d-learn
On Thursday, 15 October 2020 at 20:13:37 UTC, Atmosfear wrote: On Thursday, 15 October 2020 at 16:32:06 UTC, Imperatorn wrote: On Thursday, 15 October 2020 at 12:45:42 UTC, Atmosfear wrote: I didn't find how to call the queryperformancecounter function. I tried this. Returns errors, doesn't

Re: I need "windowsx.d" Someone can send It to me?

2020-09-26 Thread John Chapman via Digitalmars-d-learn
On Friday, 25 September 2020 at 15:03:56 UTC, Marcone wrote: I need windowsx.d but for I don't know the reason is not in dmd. Someone that have it can send to me? I don't know convert windowsx.h to windowsx.d windowsx.h is mostly a bunch of macros that forward to functions elsewhere in the

Re: Access violation when using IShellFolder2

2020-09-10 Thread John Chapman via Digitalmars-d-learn
On Thursday, 10 September 2020 at 13:30:15 UTC, FreeSlave wrote: Thanks. I tried this, but VarDateFromStr does not succeed for me. It turns out the shell embeds some control characters in the string, specifically 8206 and 8207. So remove those before passing it to VarDateFromStr. auto temp

Re: Access violation when using IShellFolder2

2020-09-10 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 9 September 2020 at 22:44:50 UTC, FreeSlave wrote: Btw do you know how to parse a date returned by GetDetailsOf? Couldn't find any examples in C++. I actually can see digits representing date and time as a part of the string, but I would prefer to use some winapi function to

Re: Access violation when using IShellFolder2

2020-09-09 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 8 September 2020 at 22:24:22 UTC, FreeSlave wrote: However if I change the type of recycleBin variable to IShellFolder (not IShellFolder2), the crash does not happen. Does IShellFolder2 require some special handling? The issue is caused by druntime's definition of IShellFolder2.

Re: final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
On Saturday, 13 June 2020 at 15:33:55 UTC, Boris Carvajal wrote: On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote: Is this a bug or have I made a mistake? This worked a few days ago and I haven't changed my setup since then. https://issues.dlang.org/show_bug.cgi?id=19548 Your

final switch problem

2020-06-13 Thread John Chapman via Digitalmars-d-learn
If I use a final switch and import std.uni (or any other module that imports it, such as std.string), I'm getting unresolved external symbol errors with DMD 2.092. This code triggers the issue: --- module test; import std.uni; enum Cheese { cheddar, edam } void test(Cheese cheese) {

Re: How to get the pointer of "this" ?

2020-05-26 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 13:37:22 UTC, Vinod K Chandran wrote: On Tuesday, 26 May 2020 at 12:41:20 UTC, John Chapman wrote: On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT Change line 124 to:

Re: How to get the pointer of "this" ?

2020-05-26 Thread John Chapman via Digitalmars-d-learn
On Monday, 25 May 2020 at 16:26:31 UTC, Vinod K Chandran wrote: Here is my full code. Please take a look. https://pastebin.com/av3nrvtT Change line 124 to: SetWindowSubclass(this.mHandle, SUBCLASSPROC(), UINT_PTR(subClsID), cast(DWORD_PTR)cast(void*)this); That is, change `` to

Overload function template for rectangular array

2020-05-25 Thread John Chapman via Digitalmars-d-learn
Is it possible to overload a function template for rectangular arrays? Is there any way to tell them apart from normal ones? void foo(T)(T[] a) {} void foo(T)(T[][] a) {} auto ra = new int[][](5, 5); ra.foo(); // matches both Thanks for any hints.

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread John Chapman via Digitalmars-d-learn
On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote: Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer. import std.string; pragma(msg, format("%x", 10)); %x = hex

Re: Win32 Api: How create Open/"Save as" Dialog?

2020-01-11 Thread John Chapman via Digitalmars-d-learn
On Saturday, 11 January 2020 at 10:34:34 UTC, Marcone wrote: This code works, but I can't get file Path. Someone can help me? import std; import core.sys.windows.windows; pragma(lib, "comdlg32"); void main(){ OPENFILENAME ofn; wchar* szFileName; You need to supply a buffer, not a

Re: ... use of ... is hidden by ...; use alias ... to introduce base class overload set ??

2019-10-21 Thread John Chapman via Digitalmars-d-learn
On Sunday, 20 October 2019 at 21:45:35 UTC, Robert M. Münch wrote: class myWidget : Observer!message {...} class FilterSubject : SubjectObject!message { Disposable subscribe(myWidget observer){...} } I tried to add "alias subscribe = SubjectObject.subscribe;" in different places, but that

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-28 Thread John Chapman via Digitalmars-d-learn
On Sunday, 27 January 2019 at 16:23:42 UTC, FrankLike wrote: On Sunday, 27 January 2019 at 10:44:04 UTC, John Chapman wrote: On Sunday, 27 January 2019 at 06:14:15 UTC, FrankLike wrote: On Saturday, 26 January 2019 at 09:33:33 UTC, John Chapman wrote: What has that code got to do with

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-27 Thread John Chapman via Digitalmars-d-learn
On Sunday, 27 January 2019 at 06:14:15 UTC, FrankLike wrote: On Saturday, 26 January 2019 at 09:33:33 UTC, John Chapman wrote: What has that code got to do with setting the console's font? So you need to add more code to accomplish that. You don't need to set the font to achieve the goal,

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-26 Thread John Chapman via Digitalmars-d-learn
On Saturday, 26 January 2019 at 06:03:25 UTC, FrankLike wrote: On Friday, 25 January 2019 at 15:05:50 UTC, John Chapman wrote: On Friday, 25 January 2019 at 14:23:15 UTC, FrankLike wrote: I need to set the font by the code now, because I need to do the installer, can't let this installer set

Re: What is the alternative to the setlocale function of c in D? Thank you.

2019-01-25 Thread John Chapman via Digitalmars-d-learn
On Friday, 25 January 2019 at 14:23:15 UTC, FrankLike wrote: I need to set the font by the code now, because I need to do the installer, can't let this installer set the properties on each computer? SetCurrentConsoleFontEx perhaps?

Re: How to split strings into AA using phobos

2018-12-11 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 11 December 2018 at 08:20:32 UTC, Arun Chandrasekaran wrote: A typical example would be to split the HTTP query string into an AA. vibe.d has req.queryString, but no convenient wrapper to access it as an AA. http://localhost/hello?name=abc=123 I've got this far. auto

Re: ElementType of MapResult is a delegate??

2018-12-08 Thread John Chapman via Digitalmars-d-learn
On Saturday, 8 December 2018 at 13:02:00 UTC, Yuxuan Shui wrote: This surprised me A LOT: https://d.godbolt.org/z/82a_GZ So if I call something.map!().array, I get an array of delegates? That makes no sense to me. But in your example, "(a) =>" returns "{return tmp;}", which is a delegate.

Ambiguous virtual function

2018-12-05 Thread John Chapman via Digitalmars-d-learn
I get an "ambiguous virtual function" error when I compile this: interface I { void fun(); } mixin template F() { void fun() {} } class C : I { mixin F; mixin F; } But the error doesn't occur with this: class C : I { mixin F; void fun() {} } Is the

Re: Function signature as string

2018-11-29 Thread John Chapman via Digitalmars-d-learn
On Thursday, 29 November 2018 at 21:31:57 UTC, Neia Neutuladh wrote: On Thu, 29 Nov 2018 21:11:06 +, John Chapman wrote: Is there any way to get a string representing a function's exact signature as declared in the source? I can generate it myself using reflection but it might not be 100%

Function signature as string

2018-11-29 Thread John Chapman via Digitalmars-d-learn
Is there any way to get a string representing a function's exact signature as declared in the source? I can generate it myself using reflection but it might not be 100% verbatim so wanted to know if there's anything built in? foreach (m; __traits(allMembers, T)) { alias member =

Re: How to center dlangui Window on screen

2018-11-29 Thread John Chapman via Digitalmars-d-learn
On Thursday, 29 November 2018 at 13:42:28 UTC, greatsam4sure wrote: Which class in dlangui is use to obtain the screen height and width? A Windom of dimension 280 x 445 in dlangui is the same as a Windom of 350 x 550 in Javafx and adobe air. What could be responsible for this wide difference?

Re: Making external types available to mixins

2018-11-24 Thread John Chapman via Digitalmars-d-learn
On Friday, 23 November 2018 at 21:49:55 UTC, Kagamin wrote: Well, just have all factories in one module and import it, then they will be visible. They're part of another library over which I have no control, but yes, I could still import them all and make life easier. import allfactories;

Re: memoize & __traits(compiles...)

2018-11-23 Thread John Chapman via Digitalmars-d-learn
On Friday, 23 November 2018 at 11:29:24 UTC, Nicholas Wilson wrote: No, std.functional.memoize uses a hashtable to cache the runtime results of calls to expensive functions. assuming that the example is not oversimplified and generateFunc1 and generateFunc2 are functions, the compiler

memoize & __traits(compiles...)

2018-11-23 Thread John Chapman via Digitalmars-d-learn
I'm doing a fair amount of repeatedly checking if a function compiles with __traits(compiles...), executing the function if so, erroring out if not, like this: static if (__traits(compiles, generateFunc1())) { return generateFunc1(); } static if (__traits(compiles, generateFunc2())) {

Re: Making external types available to mixins

2018-11-23 Thread John Chapman via Digitalmars-d-learn
On Thursday, 22 November 2018 at 16:27:08 UTC, Eduard Staniloiu wrote: So I had a go at this and I have a working solution. https://run.dlang.io/is/oaH6Ib At first, I tried to do everything in the mixin, as you can see with the `failedAttempt` function. The idea was that this should have

Re: task can't take a class method

2018-11-19 Thread John Chapman via Digitalmars-d-learn
On Monday, 19 November 2018 at 16:29:01 UTC, helxi wrote: On Monday, 19 November 2018 at 16:10:15 UTC, helxi wrote: ... Oh wait never mind I was missing a bracket: auto proc = task!(ddCall.dd()); Now I have another thing to worry about: ddcall.dd() cannot be read at compile

Re: Making external types available to mixins

2018-11-18 Thread John Chapman via Digitalmars-d-learn
On Saturday, 17 November 2018 at 21:11:38 UTC, Adam D. Ruppe wrote: On Saturday, 17 November 2018 at 17:58:54 UTC, John Chapman wrote: Has anyone had a similar need and come up with a solution? You might be able to just pass it the Calendar type, and then fetch its parent module and get the

Making external types available to mixins

2018-11-17 Thread John Chapman via Digitalmars-d-learn
The following code doesn't compile because the generated type name needs to be available inside the mixin's scope, whereas it's actually in another module. auto makeWith(string className, Args…)(auto ref Args args) { mixin("return makeWith!(I", className, "Factory)(args);"); // Fowarded to

Re: Accessing LPARAM param from SendMessage acts weird.

2018-11-04 Thread John Chapman via Digitalmars-d-learn
On Sunday, 4 November 2018 at 19:06:22 UTC, Mark Moorhen wrote: Another Windows challenge: I'm trying to get the title of the active window even if it is from an external application. This is what I've come up with so far: import std.stdio; import core.sys.windows.windows; extern

Re: Private struct constructor

2018-10-04 Thread John Chapman via Digitalmars-d-learn
On Thursday, 4 October 2018 at 07:31:21 UTC, Ritchie wrote: Any reason why this works? https://run.dlang.io/is/TALlyw "private" applies to the module, not the type. https://dlang.org/spec/attribute.html#visibility_attributes

Re: Use nested functions as callbacks with Windows API functions?

2018-10-02 Thread John Chapman via Digitalmars-d-learn
On Monday, 1 October 2018 at 20:27:43 UTC, spikespaz wrote: Of course there is nothing wrong with defining each callback as a separate function, but then comes the issue of naming them. I also don't like the way it makes my code look. I think the best you can do is something like this: ---

Re: Convert output range to input range

2018-03-17 Thread John Chapman via Digitalmars-d-learn
On Saturday, 17 March 2018 at 17:16:40 UTC, David Nadlinger wrote: On Friday, 16 March 2018 at 07:57:04 UTC, John Chapman wrote: I need to write to a range created with outputRangeObject, then read from it. Is there a way to convert it to an input range? Could you illustrate your problem a

Convert output range to input range

2018-03-16 Thread John Chapman via Digitalmars-d-learn
I need to write to a range created with outputRangeObject, then read from it. Is there a way to convert it to an input range?

Re: How to proceed with learning to code Windows desktop applications?

2018-01-31 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 31 January 2018 at 11:52:20 UTC, rumbu wrote: On Windows platform, WPF is the way to go right now. Once you accommodate yourself with XAML (descriptive language for designing windows and controls), you can step up from WPF to modern Windows apps (UWP). Unfortunately, none of

Re: Get aliased type

2018-01-02 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 12:19:19 UTC, David Nadlinger wrote: There is indeed no way to do this; as you say, aliases are just names for a particular reference to a symbol. Perhaps you don't actually need the names in your use case, though? — David The idea was to distinguish between a

Get aliased type

2018-01-02 Thread John Chapman via Digitalmars-d-learn
Because an alias of a type is just another name for the same thing you can't test if they're different. I wondered if there was a way to get the aliased name, perhaps via traits? (.stringof returns the original type.) I can't use Typedef because I'm inspecting types from sources I don't

Re: std.file and non-English filename in Windows

2018-01-01 Thread John Chapman via Digitalmars-d-learn
On Sunday, 31 December 2017 at 18:21:29 UTC, Domain wrote: In Windows, exists, rename, copy will report file not exists when you input non-English filename, such as Chinese 中文.txt Works for me. I created a file with the name "中文.txt" and std.file.exists returned true. Is your D source file

Re: Calling a d-style-variadic-function from another

2017-12-30 Thread John Chapman via Digitalmars-d-learn
On Saturday, 30 December 2017 at 10:14:35 UTC, tipdbmp wrote: // how can I adjust _argptr? _argptr = ??? Try this: _argptr = *cast(va_list*)_argptr;

Re: Is variable void?

2017-11-25 Thread John Chapman via Digitalmars-d-learn
On Saturday, 25 November 2017 at 15:38:15 UTC, Adam D. Ruppe wrote: nope. It'd be indistinguishable from the user just happening to initialize it to some random value. Thanks. I'll got with .init instead.

Is variable void?

2017-11-25 Thread John Chapman via Digitalmars-d-learn
Is there any way of determining whether a variable has been initialized or not? For example, if something is declared like this: int x = void; can I check if it's void before I use it, say, in a function it's been passed to?

Re: Whats the correct way to pass a D array type to a win32 api function wanting a buffer?

2017-07-13 Thread John Chapman via Digitalmars-d-learn
On Thursday, 13 July 2017 at 01:15:46 UTC, FoxyBrown wrote: ENUM_SERVICE_STATUS_PROCESS[5000] services; auto res = SVC.EnumServicesStatusExA(schSCManager, SC_ENUM_TYPE.SC_ENUM_PROCESS_INFO, servicesType, SERVICE_STATE_ALL, cast(ubyte*)services.ptr,

Re: COM Expertise needed: COM Callbacks

2017-04-28 Thread John Chapman via Digitalmars-d-learn
On Thursday, 27 April 2017 at 20:20:23 UTC, Nierjerson wrote: I think the main issue though, is that I really don't know what is going on when I invoke the PS function. It seems to call the server method that takes the interface and then the server does it's "magic"(which is calling my

Re: COM Expertise needed: COM Callbacks

2017-04-27 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 26 April 2017 at 23:04:53 UTC, Nierjerson wrote: On Wednesday, 26 April 2017 at 15:30:37 UTC, John Chapman wrote: On Tuesday, 25 April 2017 at 18:39:56 UTC, Nierjerson wrote: [...] When you use DISPATCH_PROPERTYPUT you need to set cNamedArgs and rgdispidNamedArgs like so:

Re: COM Expertise needed: COM Callbacks

2017-04-26 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 18:39:56 UTC, Nierjerson wrote: void RGB(icRGBColor ic, cSolidColor s) { import main; EXCEPINFO exception; uint argErr = 0; auto iidNULL = IID_NULL; auto RT = new SafeVariantPtr(); VARIANT[1] paramVars; DISPPARAMS

Re: opDispatch/template get this

2017-04-04 Thread John Chapman via Digitalmars-d-learn
On Monday, 3 April 2017 at 21:49:07 UTC, Inquie wrote: I am using opDispatch to wrap function calls Error: 'this' is only defined in non-static member functions, not opDispatch!"foo" class X { auto localfoo() { return 3; } template opDispatch(string name, Args...) {

Re: COM2D Wrapper

2017-03-28 Thread John Chapman via Digitalmars-d-learn
On Monday, 27 March 2017 at 21:02:05 UTC, Nierjerson wrote: Anyone can help get this working? I think the issue maybe that the interface pointer returned by the COM interface is "C-like" and doesn't match what D expects an interface to be. I get access violations when trying to call the

Re: Working Windows GUI library - no console Window

2015-11-06 Thread John Chapman via Digitalmars-d-learn
On Friday, 6 November 2015 at 15:52:10 UTC, johann wrote: hi, i like to use a window gui library and i think i found a working one. https://github.com/FrankLIKE/dfl2 - works with x64 the problem is, that with DMD 2.069.0, VS2015 and visualD the trick of using "-L/SUBSYSTEM:windows,6.00

Re: how to iterate on Array?

2015-06-27 Thread John Chapman via Digitalmars-d-learn
On Saturday, 27 June 2015 at 17:43:13 UTC, aki wrote: I want to print the contents of Array!int import std.stdio; import std.container; void pr(Array!int a) { foreach(i, v; a[]) { writeln(%4s: %s\n, i, v); } } But when I compile it by DMD 2.062 on Windows it

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:50:27 UTC, John Chapman wrote: wchar[MAX_PATH] buffer; int length = GetWindowTextW(GetForegroundWindow(), buffer.ptr, buffer.length); Don't know why I used MAX_PATH there. You should probably dynamically allocate a buffer based on GetWindowTextLengthW.

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 21:00:55 UTC, Dan wrote: thank you John it worked :) do I always need do the same for all windows API? For most Win32 API functions, yes. Although there are some more complete headers on Github (for example, https://github.com/rikkimax/WindowsAPI).

Re: Can't call GetWindowTextW - Error:undefined identifier

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 20:40:02 UTC, Dan wrote: I'm new to Dlang and I have no Idea whats wrong with this code! wchar[260] buffer; HWND hWindow = GetForegroundWindow(); GetWindowTextW(hWindow, buffer, sizeof(title)); -- Problem here The compiler is complaining it can't find an

Re: Calling a cpp function from d

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23,

Re: Calling a cpp function from d

2015-06-17 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23,

Re: Calling a cpp function from d

2015-06-16 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23, null, 0, buf.ptr);

Re: windows wininet library

2015-02-01 Thread John Chapman via Digitalmars-d-learn
On Sunday, 1 February 2015 at 08:37:23 UTC, ketmar wrote: seems that my idea of using D to write a simple windows utility was very wrong. ok, another attempt to use D for our windows developement has failed. i'm in no way can sell manual .def creation to our team -- they will make fun of me,

Re: sign oauth request

2014-09-25 Thread John Chapman via Digitalmars-d-learn
there is no HMAC-SHA1 algorithm in phobos library... should I implement it from scratch? http://dlang.org/phobos/std_digest_sha.html#SHA1