D - Resource files
- Mårten Ask (3/3) Oct 23 2003 Hi, I'm trying to build a GUI using the windows API. Some of the functio...
- J C Calvarese (18/21) Oct 23 2003 I'm not sure exactly where you're running to problems, so I'll just
- Mårten Ask (48/108) Oct 24 2003 Thanks!
- Vathix (6/9) Oct 24 2003 What I do is:
- Mårten Ask (5/14) Oct 24 2003 Thanks! I'll continue tinkering and see if I can get it right..
- Charles Sanders (4/22) Oct 27 2003 Marten do you still have that CGI module ?
- Mårten Ask (132/158) Oct 27 2003 Yup. Here it is. It's not at all done yet, It doesn't understand what
- J C Calvarese (15/65) Oct 24 2003 Examples are always good.
Hi, I'm trying to build a GUI using the windows API. Some of the functions expects me to use a resource file, then compile and link it with the executable. How do I do that?
Oct 23 2003
Mårten Ask wrote:Hi, I'm trying to build a GUI using the windows API. Some of the functions expects me to use a resource file, then compile and link it with the executable. How do I do that?I'm not sure exactly where you're running to problems, so I'll just explain a little of what I know about resource files and attach an example. Typically, one has a resource script (.rc) that is compiled into a resource file (.res) by a resource compiler (such as Digital Mars' RCC.EXE, which is available for free). Then the compiled resource is attached to the compiled executable. With DMD, the resource file is simply added as a command line argument like this: dmd whatever.d resource.res My very simple example ----------------------------------------------------------------- compile_rc.bat: a batch file to automate the whole process whatever.d: a minimalist D source file that doesn't do anything resource.rc: an example of a resource script w.ico: an icon resource called by the resource script I hope this helps. Justin
Oct 23 2003
Thanks! I wasn't very clear in my first post, I understand what a resource file is and what it does. It's just that every example I've seen on how to use them have been written in C or C++. Like this example: resource.h ------------ #define IDR_MYMENU 101 #define IDI_MYICON 201 #define ID_FILE_EXIT 9001 #define ID_STUFF_GO 9002 resource.rc ------------ #include "resource.h" IDR_MYMENU MENU BEGIN POPUP "&File" BEGIN MENUITEM "E&xit", ID_FILE_EXIT END POPUP "&Stuff" BEGIN MENUITEM "&Go", ID_STUFF_GO MENUITEM "G&o somewhere else", 0, GRAYED END END IDI_MYICON ICON "menu_one.ico" Then include resource.h and register the menu and the icons in the WinMain function: wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON)); wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0); How do I translate all that to D? Do I write a resource.d file and use extern (C) to fetch the variables in resource.h? Help! "J C Calvarese" <jcc7 cox.net> skrev i meddelandet news:bn9ml7$27et$1 digitaldaemon.com...Mårten Ask wrote:functionsHi, I'm trying to build a GUI using the windows API. Some of theexample.expects me to use a resource file, then compile and link it with the executable. How do I do that?I'm not sure exactly where you're running to problems, so I'll just explain a little of what I know about resource files and attach anTypically, one has a resource script (.rc) that is compiled into a resource file (.res) by a resource compiler (such as Digital Mars' RCC.EXE, which is available for free). Then the compiled resource is attached to the compiled executable. With DMD, the resource file is simply added as a command line argument like this: dmd whatever.d resource.res My very simple example ----------------------------------------------------------------- compile_rc.bat: a batch file to automate the whole process whatever.d: a minimalist D source file that doesn't do anything resource.rc: an example of a resource script w.ico: an icon resource called by the resource script I hope this helps. Justin---------------------------------------------------------------------------- ----echo off echo Compiling resource file... rem rc /r resource.rc rcc resource.rc -v -32 dmd whatever.d resource.res pause erase resource.res erase whatever.map erase whatever.obj---------------------------------------------------------------------------- ----void main() { }---------------------------------------------------------------------------- ----1000 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "w.ico" 1 VERSIONINFO FILEVERSION 1, 2, 3, 4 PRODUCTVERSION 1, 2, 3, 4 FILEOS 0x4 FILETYPE 0x1 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904B0" BEGIN VALUE "LegalCopyright", "(c) 2002 Some Body" VALUE "FileDescription", "This program does awesome stuff!" VALUE "Author", "Some Body" VALUE "CompanyName", "XYZ Corp." VALUE "ProductName", "Acme Program" VALUE "FileVersion", "1.2.3" VALUE "ProductVersion", "1.2.3" VALUE "InternalName", "something" VALUE "OriginalFilename", "something.exe" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 0x04B0 END END---------------------------------------------------------------------------- ----
Oct 24 2003
resource.h ------------ #define IDR_MYMENU 101What I do is: const char* IDR_MYMENU = cast(char*)101; You can use IDR_MYMENU without using MAKEINTRESOURCE; make sure those values don't get larger than short.max. I have to put the actual values in the resource file. It would be nice if there was a resource file just for D that you could use import.
Oct 24 2003
Thanks! I'll continue tinkering and see if I can get it right.. "Vathix" <vathix dprogramming.com> skrev i meddelandet news:bnavtu$1aoq$1 digitaldaemon.com...valuesresource.h ------------ #define IDR_MYMENU 101What I do is: const char* IDR_MYMENU = cast(char*)101; You can use IDR_MYMENU without using MAKEINTRESOURCE; make sure thosedon't get larger than short.max. I have to put the actual values in the resource file. It would be nice if there was a resource file just for Dthatyou could use import.
Oct 24 2003
Marten do you still have that CGI module ? C "Mårten Ask" <majbritt37 hotmail.com> wrote in message news:bnb3d2$1f9r$1 digitaldaemon.com...Thanks! I'll continue tinkering and see if I can get it right.. "Vathix" <vathix dprogramming.com> skrev i meddelandet news:bnavtu$1aoq$1 digitaldaemon.com...valuesresource.h ------------ #define IDR_MYMENU 101What I do is: const char* IDR_MYMENU = cast(char*)101; You can use IDR_MYMENU without using MAKEINTRESOURCE; make sure thosedon't get larger than short.max. I have to put the actual values in the resource file. It would be nice if there was a resource file just for Dthatyou could use import.
Oct 27 2003
Yup. Here it is. It's not at all done yet, It doesn't understand what file-uploading is. But it works for simple apps. "Charles Sanders" <sanders-consulting comcast.net> skrev i meddelandet news:bnjg2v$2beq$1 digitaldaemon.com...Marten do you still have that CGI module ? C "Mårten Ask" <majbritt37 hotmail.com> wrote in message news:bnb3d2$1f9r$1 digitaldaemon.com...theThanks! I'll continue tinkering and see if I can get it right.. "Vathix" <vathix dprogramming.com> skrev i meddelandet news:bnavtu$1aoq$1 digitaldaemon.com...valuesresource.h ------------ #define IDR_MYMENU 101What I do is: const char* IDR_MYMENU = cast(char*)101; You can use IDR_MYMENU without using MAKEINTRESOURCE; make sure thosedon't get larger than short.max. I have to put the actual values inDresource file. It would be nice if there was a resource file just forbegin 666 cgi.zip MS4\IS4E5R$TM*DG-TTM.SP3AU**B_")K7BY>+GTM!6=W3U<07Z$D(S,/**> MI<_+E9R36%R,D+)2`-.\7-6\7 I `%1:K)&<D5 4':L`-DP3( Z5!H'BTH+4 M;*X2J9"44V-P_^W^QXZB9+TX;HMUP 3XA>3=<Z=[[HZ7R;A($3)4!D48S7F8 M2)4-]_?V]W+%E\P \"R7RD 4:A.G_/X8M%%<S,M?9%:V)]D"*U3ZU7/ZH%)2 M=0Q&"Z:F,YBC&8NE7ZUTL+_WU_X>T*/0%$I4;H1&WI9__-K!D!21%$O-PT ' MIK$NW;>GVQ8H` [92& ""%%&G!F^1&!*L17(I'H371JW*$O)8X=3O_V2%H$[ M^J 4:PE*Y7-A )/\8$ _OY!NF**8FP4MCXZ"1K;E:ZEZUK>1G$[YC(R,.K[8 MAR>^B^TT.9L.9K/*`OP* P!.3N 3KH"E,65 O +\S+7178">;?M4P;2J(^B M:U]NO;T5,1,M_K4AS_NVE74[9M79NE4M"9('5"YF 92T:8&V'IBKGM)>6)6[ M!LQRLZK2!Z2 A/&T4!A6^(>4,I!)A81%A28%. !8, >O688 [!<W&U ZR"B/ M4NIF2!5'91]O\.XIPV [XY%,I=C8J8JTZ5)U_]EDUW:E=OCLA;=J9]0H8HQD MC'7>$]"L716MR/9XZP&:A9*/(/ 1WIQ?C&U[];VW92ABB5H\-ZY>7H'-;.ON M[!5![O_D?8.3.DB6"!?+DAT-CYQZY":>VM)C;YW>3=/4S%S*V*) 5J2&YS0* MQETU5O/[+AMGE*X7,M10:/5IKQ?>9E$1W_%X(U (; QJL_6^;D: G$Q9<MW2 M;QO)0W>?>V)T^8S]; > H]?ZT\%\].+EP0+_'"TP367S[ZR3`30UT,SDYV'3 M^W4U>M'P=?+40,GEL)K,WMJ>4 9)V6["8LIN)3.P0B*$0I?=(>:*LC-=V=%J MD6L&U5#JO;F^FHRO)G?OQU?GDW=>IQ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_<<M=M.)L1Y-ATMWG_^\.G+OQ]O M_OIM-*VB/%3.KF: N2VU-$Y)-!1:R8)+"UNF!5MB89",A*U%T%NNOX;529B5 M7B[3T2LH=D.H9]+T-D\BNFF<LUJO_OPY:#N M\*70E*JC\ 9VPJY<D9,]C)^1->>LE;;+1#W\$M7ZO/D+N&+5R9-??%+LA&*' MR^PI.GG7! NSE/ZL&Z,2P:S8\HO*^']WY,B'[+NIF\1N&L #L8>S3<>LE33\ M;-?QD+KM]'85%&[%6<JU:3>;99EE7%]J-SUMHJNJX=8XC)<T`B7S?95004L\ M"F->!: ]>Y>5K^"G9Z,[+2Q6S!B+8DQI0IRF3N:5;._/8:OMH<$QKV#UZ#KL MZ6C,2>LSV [AYTY+>!PRU '%)/CCZ"V,'AVV]["D*$]B?7]<:K7#SDS;'N<J MP6.BY+C-IS*H&%6P8Q[5"M;6Z,_P352J^;B7<F>U[V"OM5ISC=5'[899R]/: MB<TOJDU316CTC"><E&%I"G:G(!>2+S5GWPTL.2[CA2+W6/(NT(O*O'W5H8L_ M^$1Z+[RKTUMH5$>+Z]M#XD9QRWMO935Z1YV#N(EMOS._*2$KN5"D?^3HTNOR MQ$UQ2/T[MW"ZB=27=3>**VD?I-H0PW[6=R5E>6E6?5>\9X%789G;N!F:)C"/ MS=)\Q.WBAH]A*&.+)/T<N6SB$=V^]Q-02P,$" ``````3V]*+P`````````` M``````0```!C9VDO4$L!`A0`% ```` `);E;+[RM0 UG````D ````X````` M`````0` `+:!`````&-G:2]C9VEE<G)O<BYD4$L!`A0`% ```` `*[E;+S&7 M>!I\! ``8 T```H``````````0` `+:!DP```&-G:2]F;W)M+F102P$"% `4 M;VMI92YD4$L!`A0`% ```` `.+E;+_+ BF8;! ``:PX```D``````````0` M``````````$`( "V :H,``!C9VDO:'1M;'1E;7!L871E+F102P$"% `4```` M``!C9VDO;6%I;BYD4$L!`A0`" ``````3V]*+P````````````````0````` ` endthatyou could use import.
Oct 27 2003
Mårten Ask wrote:Thanks! I wasn't very clear in my first post, I understand what a resource file is and what it does. It's just that every example I've seen on how to use them have been written in C or C++.Okay, maybe someone else benefited from reading that reply, then...Like this example:Examples are always good.resource.h ------------ #define IDR_MYMENU 101 #define IDI_MYICON 201 #define ID_FILE_EXIT 9001 #define ID_STUFF_GO 9002 resource.rc ------------ #include "resource.h" IDR_MYMENU MENU BEGIN POPUP "&File" BEGIN MENUITEM "E&xit", ID_FILE_EXIT END POPUP "&Stuff" BEGIN MENUITEM "&Go", ID_STUFF_GO MENUITEM "G&o somewhere else", 0, GRAYED END END IDI_MYICON ICON "menu_one.ico" Then include resource.h and register the menu and the icons in the WinMain function: wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON)); wc.hIconSm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON), IMAGE_ICON, 16, 16, 0); How do I translate all that to D? Do I write a resource.d file and use extern (C) to fetch the variables in resource.h?One thing that I've been doing is creating a simple .h file and then running my simple h_to_d program on it to create a .d file that can be imported. h_to_d.exe resource.h creates resource.d (it only works on very simple .h files). I put it up at my website in case you're interested in trying it out: http://jcc_7.tripod.com/d/h_to_d.zip. It's not fancy, but it's been useful for me. Also, I attached the file it generated from your example. Justin http://jcc_7.tripod.com/d/Help!...
Oct 24 2003