Re: How does one attach a manifest file to a D executable on Windows?

2024-06-02 Thread John Chapman via Digitalmars-d-learn
On Sunday, 2 June 2024 at 21:46:41 UTC, solidstate1991 wrote: Well, it turns out I used the windres found in mingw instead of `rc.exe` since the latter cannot be found anywhere on my PC, even after reinstalling stuff. I need to hunt it down somehow. rc.exe comes with the Windows SDK - it gets

Re: How does one attach a manifest file to a D executable on Windows?

2024-05-25 Thread John Chapman via Digitalmars-d-learn
On Saturday, 25 May 2024 at 13:13:08 UTC, solidstate1991 wrote: No, I meant something like this: https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview Not tested but from memory I do this: 1) Copy that first XML snippet from the page you linked, save to a file called exa

Re: Getting a total from a user defined variable

2023-04-20 Thread John Chapman via Digitalmars-d-learn
On Thursday, 20 April 2023 at 19:41:21 UTC, Joel wrote: // how do I get the total of ages added together? p.map!(x => x.age).sum();

Re: How can a function pointer required to be extern(C)?

2023-04-12 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 12 April 2023 at 20:36:59 UTC, H. S. Teoh wrote: ---snip--- extern(C) void* abc(void*) {return null;} alias FuncPtr = typeof(&abc); You can also express it like this: ```d extern(C) alias FuncPtr = void* function(void*); ```

Re: staticMap but with two arguments

2023-02-09 Thread John Chapman via Digitalmars-d-learn
On Thursday, 9 February 2023 at 19:17:55 UTC, Ali Çehreli wrote: I could not figure out eliminating the hard-coded 4. Can we introspect the parameter list of a template like 'fun' in the example? If we could, then we could get 4 that way. Thank you for this. I don't mind hard-coding the N argu

Re: staticMap but with two arguments

2023-02-08 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: So I've got this implementation, but wonder if I can generalise the arg splitting portion rather than write it manually for each N? ```d template staticMapN(size_t N

Re: staticMap but with two arguments

2023-02-06 Thread John Chapman via Digitalmars-d-learn
On Monday, 6 February 2023 at 09:17:07 UTC, Ali Çehreli wrote: I adapted staticMap's implementation to two sets of arguments: Thanks Ali, that's perfect. I thought of splitting the args in half a few hours later but hadn't got around to trying it.

staticMap but with two arguments

2023-02-05 Thread John Chapman via Digitalmars-d-learn
I have two AliasSeqs: one containing a function's parameters (SourceSeq), the other containing the types I want to convert said parameters to (TargetSeq). I'd use something like staticMap to call the conversion function with both a parameter from SourceSeq and a type from TargetSeq, and return

Re: Mixin helper help

2023-01-14 Thread John Chapman via Digitalmars-d-learn
On Friday, 13 January 2023 at 14:32:44 UTC, Salih Dincer wrote: Why not directly use the mixin template for opDispatch()? My opDispatch generates code based on the arguments passed, interpolating variable names and functions based on the type. I wanted to remove the double braces in my static

Mixin helper help

2023-01-12 Thread John Chapman via Digitalmars-d-learn
I'm obviously doing something wrong, but don't quite understand. ```d mixin template helper() { mixin("writeln(12);"); } struct Foo { void opDispatch(string name)() { import std.stdio; mixin helper!(); //mixin("writeln(12);"); } } void main() { Foo.init.opDispatch!"bar"(); }

Re: How to add struct definition?

2022-09-08 Thread John Chapman via Digitalmars-d-learn
On Friday, 9 September 2022 at 00:16:01 UTC, Injeckt wrote: I need to add this struct definition in my project. But how to do that? This structure: https://docs.microsoft.com/en-us/windows/win32/api/iptypes/ns-iptypes-ip_adapter_info It's defined in DRuntime, so you can just import the module

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 kno

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 SD

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-09 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 trans

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. T

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

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) { final

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(&btnWndProc), UINT_PTR(subClsID), cast(DWORD_PTR)cast(void*)this); That is, change `&this`

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 poin

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 di

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 achiev

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 installe

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? https://docs.microsoft.com/en-us/windows/console/setcurrentco

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&id=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. J

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 com

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 b

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 = __traits

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; a

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 doesn't

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 worke

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 time

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 i

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 (Windows)

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: --- au

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 these

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 contr

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 s

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, 5000*ENUM_SERVICE_STATUS_PROCESS.siz

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 QueryI

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 param

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...) { static

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 functio

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 -L/

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 s

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: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 GetWindowTextLe

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 identifi

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: GetModuleHandle

2015-04-22 Thread John Chapman via Digitalmars-d-learn
On Wednesday, 22 April 2015 at 18:31:20 UTC, Laeeth Isharc wrote: Hi. I am trying to use the Excel API with latest release dmd on Win 32. It looks like GetModuleHandle isn't in the D windows header anymore. Should I try to use GetModuleHandleA or B ? Thoughts? Import core.sys.windows.win

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

Re: BSTR to string?

2014-02-08 Thread John Chapman
On Saturday, 8 February 2014 at 12:34:44 UTC, Andre wrote: Hi, I have an IHTMLElement and want the tag name. HRESULT get_tagName(ref BSTR); IHTMLElement htmlElement; BSTR tagName; ... htmlElement.get_tagName(tagName); writeln(to!string(*tagName)); I tried different combinations but the result

Re: Interfaces allow member definitions?

2014-01-30 Thread John Chapman
On Thursday, 30 January 2014 at 14:31:05 UTC, Frustrated wrote: I'm not asking about a work around but if what I am talking about can actually be done(does the vtable support this or can made to support it?) It would work if you changed the interface to an abstract class.

Re: Win32 with D: Using RegisterClassExA instead of RegisterClass

2014-01-28 Thread John Chapman
On Tuesday, 28 January 2014 at 21:17:18 UTC, BeschBesch wrote: My problem: Using WNDCLASS and RegisterClass works out fine but when I try the Ex-versions (RegisterClassExA/WNDCLASSEX) windows returns a INVALID_PARAMETER error, though I did not change anything besides adding "Ex". Where is the mi

Re: Invalid conversion from utf8 string when it is in variable

2013-01-28 Thread John Chapman
On Monday, 28 January 2013 at 11:17:02 UTC, rsk82 wrote: The effect here is that the message text is correct in greek letters but message title is all empty boxes, sometimes with other texts there are chinese chars. string msg= "ένα μήνυμα"; MessageBoxW(null, "ένα μήνυμα", cast(wchar*)msg.toSt

Re: Passing rvalues to functions expecting const ref

2012-12-23 Thread John Chapman
On Sunday, 23 December 2012 at 12:08:47 UTC, Namespace wrote: As long as you use structs this should work, as you can see here: http://dpaste.dzfl.pl/03adf3d1 But if you use classes, it does not work anymore. So I like it a lot, that it works with structs. :) I don't think this will work after

Re: Need help understanding Tuple

2012-12-18 Thread John Chapman
On Tuesday, 18 December 2012 at 11:06:12 UTC, d coder wrote: Greetings Somebody please help me understand why we need the Tuple template in the following code. Does not __traits(getAttributes, foo.a) return a tuple? So what is the Tuple template doing here? Converting a tuple to a tuple? Al

Re: Programming with windows api (windows.h)

2012-12-17 Thread John Chapman
HGLOBAL data = GetClipboardData(CF_TEXT); Oops, should be CF_UNICODETEXT (13)

Re: Programming with windows api (windows.h)

2012-12-17 Thread John Chapman
On Monday, 17 December 2012 at 16:21:09 UTC, monarch_dodra wrote: I'm a bit confused about how to interface with windows.h. All I'm trying to do is retrieve some text from my clipboard to print it. Something like this: HWND hwnd = ... // your window handle (or null) if (OpenClipboard(hwnd))

Re: Calling main() from WinMain()

2012-06-06 Thread John Chapman
On Wednesday, 6 June 2012 at 02:52:39 UTC, BLM768 wrote: I've researched this some more, and it appears that WinMain() actually doesn't do any runtime initialization. That means I should be able to just call the C main from WinMain() and let it initialize the runtime and call _Dmain(). The main

Re: Problem using Interfce

2012-05-14 Thread John Chapman
On Monday, 14 May 2012 at 11:08:09 UTC, Stephen Jones wrote: I have a Widget interface which I was hoping would allow me to subsume a set of classes {Button, Cursor, etc} as being Widgets so I could keep an array of buttons, cursors, etc by initializing them as Widgets. private Widget[] widget

Re: variadic mixin templates and other stuff

2012-04-20 Thread John Chapman
On Friday, 20 April 2012 at 14:57:03 UTC, Martin Drasar wrote: On 20.4.2012 16:09, Timon Gehr wrote: I tried but it still refuses to compile: string interfaceGuid(string ifaceName) { return ifaceName ~ "Guid"; } mixin template EXPOSE_INTERFACES(T...)(T args) Try this: mixin template EXP

Re: delegates vs functions => practical consequences

2012-04-18 Thread John Chapman
On Wednesday, 18 April 2012 at 21:07:08 UTC, Xan wrote: Hi, I want to know what is most interesting for me: delegates or functions. I consulted sources but none say the practical consequences of such election. What can I do and what can't I do with functions and delegates? Please, be didacti

Re: Templates in classes => what is wrong?

2012-04-15 Thread John Chapman
On Sunday, 15 April 2012 at 11:16:43 UTC, Xan wrote: int main(string [] args) { auto alg = Algorisme!(int,int); Should be: auto alg = new Algorisme!(int, int); alg.nom = "Doblar"; alg.versio = 1; alg.funcio = (int a) {return 2*a}; Should be: alg.funcio = (int a)

Re: trouble calling function from windows dll

2012-03-25 Thread John Chapman
On Saturday, 24 March 2012 at 19:11:38 UTC, maarten van damme wrote: hi, I'm trying to call NtUnmapViewOfSection from ntdll.dll. According to the msdn docs it should look like NTSTATUS NtUnmapViewOfSection( __in HANDLE ProcessHandle, __in_opt PVOID BaseAddress ); I tried to call it

Re: trouble calling function from windows dll

2012-03-25 Thread John Chapman
On Saturday, 24 March 2012 at 19:11:38 UTC, maarten van damme wrote: hi, I'm trying to call NtUnmapViewOfSection from ntdll.dll. According to the msdn docs it should look like NTSTATUS NtUnmapViewOfSection( __in HANDLE ProcessHandle, __in_opt PVOID BaseAddress ); I tried to call it