Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Adding an icon to a saved file

eduardofrozzaeduardofrozza Member Posts: 21
Im developing a MDI application in BCB and I wish the user could save his projects as a file with a characteristic extension. Just like WinWord documents have a .doc extension and a BCB project has a .bpr extension.
Then I have two problems.
1) Files with unknown extensions to the system (Id like to use .tcx) get a standard Windows icon. Id like to know how to add my own Icon to the saved file.
2) How can I call my main application and load the data from the file when the user double-clicks the file?
Thanks.

Comments

  • JackPackJackPack Member Posts: 7
    : Im developing a MDI application in BCB and I wish the user could save his projects as a file with a characteristic extension. Just like WinWord documents have a .doc extension and a BCB project has a .bpr extension.
    : Then I have two problems.
    : 1) Files with unknown extensions to the system (Id like to use .tcx) get a standard Windows icon. Id like to know how to add my own Icon to the saved file.
    : 2) How can I call my main application and load the data from the file when the user double-clicks the file?
    : Thanks.
    :

    hi there.
    well, i don't know what how to solve your first problem, but i think
    i can help you about the second one, you can tell windows to relate
    files to a program.
    you can do that in two different ways:
    1. select one of the files witch you want to relate to your program
    and press on it, then a new option will
    appear "open with", click it and in the dialog box mark the v
    below, then select "other" and select your program file.
    now, each time you double click a file of the same type windows
    will automaticly relate it to your program.
    2. at the "view" select "folder options" then "file types" then
    "new type".
    this way is better, by the way, so you better try it before.

    i hope i've been helpful to you.
  • eduardofrozzaeduardofrozza Member Posts: 21
    Yes, you really helped.
    But now I have one more question. Where does Windows keep the information that relates the extension to the executable? Is there a way to edit this information so that the relation will be promptly made when the program is installed or executed for the first time?

  • JackPackJackPack Member Posts: 7
    : Yes, you really helped.
    : But now I have one more question. Where does Windows keep the information that relates the extension to the executable? Is there a way to edit this information so that the relation will be promptly made when the program is installed or executed for the first time?
    :
    :


    sorry, but i have no clue how to do that.
  • cruz_marc2002cruz_marc2002 Member Posts: 2
    : : Im developing a MDI application in BCB and I wish the user could save his projects as a file with a characteristic extension. Just like WinWord documents have a .doc extension and a BCB project has a .bpr extension.
    : : Then I have two problems.
    : : 1) Files with unknown extensions to the system (Id like to use .tcx) get a standard Windows icon. Id like to know how to add my own Icon to the saved file.
    : : 2) How can I call my main application and load the data from the file when the user double-clicks the file?
    : : Thanks.
    : :
    :
    : hi there.
    : well, i don't know what how to solve your first problem, but i think
    : i can help you about the second one, you can tell windows to relate
    : files to a program.
    : you can do that in two different ways:
    : 1. select one of the files witch you want to relate to your program
    : and press on it, then a new option will
    : appear "open with", click it and in the dialog box mark the v
    : below, then select "other" and select your program file.
    : now, each time you double click a file of the same type windows
    : will automaticly relate it to your program.
    : 2. at the "view" select "folder options" then "file types" then
    : "new type".
    : this way is better, by the way, so you better try it before.
    :
    : i hope i've been helpful to you.
    :

    Yes that's cool. But do you know how to automatically do
    that by programming in BCB or any language?



  • WarlockzzzWarlockzzz Member Posts: 131
    : Im developing a MDI application in BCB and I wish the user could save his projects as a file with a characteristic extension. Just like WinWord documents have a .doc extension and a BCB project has a .bpr extension.
    : Then I have two problems.
    : 1) Files with unknown extensions to the system (Id like to use .tcx) get a standard Windows icon. Id like to know how to add my own Icon to the saved file.
    : 2) How can I call my main application and load the data from the file when the user double-clicks the file?
    : Thanks.
    :

    [b][blue]Maybe this would help :[code]
    REGEDIT4

    [HKEY_CLASSES_ROOTmyprog]
    /* txt icons*/
    [HKEY_CLASSES_ROOTmyprog\DefaultIcon]
    @="C:\WINDOWS\SYSTEM\shell32.dll,-152"
    [HKEY_CLASSES_ROOTmyprog\shell]
    [HKEY_CLASSES_ROOTmyprog\shellopen]
    /* program called when dclicked*/
    [HKEY_CLASSES_ROOTmyprog\shellopencommand]
    @="myprog %l"
    /* assosiate extension with your prog */
    [HKEY_CLASSES_ROOT.tcx]
    @="myprog"[/code]
    [/blue][/b]

    Warlockzzz
    "I am not sleeping, I am slimply preparing myself to work!"

  • the_shrubbthe_shrubb Member Posts: 6
    : : Yes, you really helped.
    : : But now I have one more question. Where does Windows keep the information that relates the extension to the executable? Is there a way to edit this information so that the relation will be promptly made when the program is installed or executed for the first time?


    I'm not sure if this is exactly what you mean, but you have to force your program to edit the Windows registry.
    I think the values go in HKEY_CLASSES_ROOT, but your going to want to do some research into adding registry keys. I believe there's a windows utility that adds these values for you, based on command line switches. Something like regsvr or something, but that's a guess. I know most installer packages allow for the adding of registry keys upon install (installshield does it, windows installer does it). I know this is all pretty vague, but maybe it'll give you something to search around for. Hope this helps!
  • BriballBriball Member Posts: 265
    Ahem...

    Having the program execute upon double-clicking is done from the Registry, in the HKEY_CLASSES_ROOT key. Every file extension has its own key in HKEY_CLASSES_ROOT. The icon issue is stored in the default icon key in that "folder." You must have an icon created and ready, then that .ico path is entered into that key.

    The best way to do it is to create a .reg file in the same folder as your app, and have your app execute it upon startup. Check the other replies, someone gave the syntax.

    Another way is using the win32 api. Since it is a Windows creation it interfaces well with other Windows functions (imagine that!). Hope this all helps a little.
  • eduardofrozzaeduardofrozza Member Posts: 21
    Thanks. It worked.

  • cruz_marc2002cruz_marc2002 Member Posts: 2
    : : : Yes, you really helped.
    : : : But now I have one more question. Where does Windows keep the information that relates the extension to the executable? Is there a way to edit this information so that the relation will be promptly made when the program is installed or executed for the first time?
    :
    :
    : I'm not sure if this is exactly what you mean, but you have to force your program to edit the Windows registry.
    : I think the values go in HKEY_CLASSES_ROOT, but your going to want to do some research into adding registry keys. I believe there's a windows utility that adds these values for you, based on command line switches. Something like regsvr or something, but that's a guess. I know most installer packages allow for the adding of registry keys upon install (installshield does it, windows installer does it). I know this is all pretty vague, but maybe it'll give you something to search around for. Hope this helps!
    :

    If you are using BCB, you can use the TRegistry class.
    This class can directly changed the entries in the registry.
    You must take extra caution when editing the registry.
    For more info about the win registry, try checking these sites:
    http://www.systweak.com/winreg/winreg.htm
    http://www.winguides.com/registry/category.php/204/


  • Andre YoungAndre Young USAMember Posts: 0

    { http://forcoder.org } free video tutorials and ebooks about \ Java PHP Go PL/SQL Python Ruby R Swift Delphi Assembly MATLAB Visual Basic JavaScript Visual Basic .NET Scratch Perl C# Objective-C C C++ F# VBScript FoxPro Lisp Prolog Clojure Hack Kotlin Logo ML Awk COBOL Crystal Scala Scheme D ABAP Julia Ada Transact-SQL Rust Alice LabVIEW Apex Bash Fortran SAS Lua Dart Erlang \ _

Sign In or Register to comment.