|
My program, the one that I am writing, allows the user to create or open a project. My program s projects are basically websites, that have a sql server, a database, themes, payment gateway, shipping and freight companies, all kinds of things that need to be programed and selected for online sales.
The project file would be clicked on from my Open Project Dialog Window. I already wrote the Open Project, and Create Project Dialogs.
The VS Project File appears to be what I'm looking for as an analogy, and it seems to contain information stored in a manner that I wish to imitate.
So I want to create a file from scratch when a project is created, with my programs icon associated with it, that will store values that have been programed into the project.
When the project is selected, my program's project editor will display the stored values inside the project file.
I just need a point in the right direction as to how to get started.
Sorry for being so vague on the first post Dave, I didn't want to post too much information at first.
|
|
|
|
|
Jim,
If you are using the MFC framework then file association is available through the CWinApp::RegisterShellFileTypes[^] if you are using a CWinApp derived application. On OS >= Windows Vista you might want to do this from the installer because it requires Administrative privileges. However... you can get around this by calling RegOverridePredefKey[^] and mapping HKEY_CLASSES_ROOT to HKEY_CURRENT_USER.
The contents of your 'registered file type' can be anything you want... Text, XML, Key/Value pairs, Binary or GobbledyGook. I believe the Visual Studio project files are XML so you might want to look into some XML readers/writers such as TinyXML, XMlLite or MSXML.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks Randor.
I'm just going to try CreateFile, and figure out how structure my project data that I want to store in it. I'm writing the code right now for it to at least create the file.
I can associate the icon with install shield, and tie the icon to my project file extension. That part is not a big deal.
|
|
|
|
|
jkirkerx wrote: I can associate the icon with install shield, and tie the icon to my project
file extension. That part is not a big deal.
Well that is why everyone has been asking you: What exactly do you need help with?
|
|
|
|
|
How to package or structure the contents of the datafile that I want to write using CreateFile. How to write out the data, like a dat file, or something.
I'm sorry, I'm sick today, my head must be really fuzzy, must of picked up something in Vegas last weekend. I'm going home now, look for some cold pills.
Thanks Randor.
|
|
|
|
|
Hey Jim,
jkirkerx wrote: How to package or structure the contents of the datafile that I want to write
using CreateFile. How to write out the data, like a dat file, or something.
Well that is a really broad subject. I have already suggested XML and other plain text alternatives. If you just want to dump a bunch of structs into a file in binary format then you might want to look at the CArchive Class[^].
jkirkerx wrote: must of picked up something in Vegas last weekend
Hang on... you know the drill. What happens in Vegas... stays in Vegas.
|
|
|
|
|
That looks promising, and points me towards being able to do some research on the subject. I never thought of being able to dump a structure in memory to a file. I think that will do the trick for now.
Thanks Randor
|
|
|
|
|
I try to create a program through the C language by forming a pyramid with the GCC
can anybody help me http://undermediafire.com
|
|
|
|
|
And what exactly does that have to do with this thread? Start a new thread and show the code you have so far.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I have a simple MFC data acquisition app that runs on windows. I wanted to make a small iPhone/ipad app that talks to my windows app every 10 msec or so. Equivalent to what you would do with pocketPC thing. I just need to send simple text file with some simple commands so both sides can see the commands and act upon it. I am not sure how do I go about sharing a file between the 2 sides? iCloud? ..etc? Any ideas or someone with similar experience?
Thanks
|
|
|
|
|
Software2007 wrote: I wanted to make a small iPhone/ipad app that talks to my windows app every 10 msec or so. this indicates that you want the iOS app to upload that file to your MFC app.
Software2007 wrote: I am not sure how do I go about sharing a file between the 2 sides? iCloud? this indicates that you want to have both sides accessing the same content (file) practically at the same time.
Which is it? If it is the first situation, then i guess HTTP should work.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
It is more like the second. I would like to send commands between the two sides via a text file, or it could be two text files, win_to_ios.txt and iOS_to_win.txt. The point is how and where do these files go so that both sides can be looking at the file(s) of interest?
For instance, on the iPhone side, I might have screen with buttons a,b,c, when 'a' is pushed I would like to write 'a' to some file, the MFC on windows would look at this file every 10 ms , would read the 'a' and launch a missile. I know, I wouldn't be launching a missile every 10 ms ...I understand this has to be a shared network thing, but I was just wondering what would be the easiest solution since this is nothing but sharing a text file.
modified 23-Mar-12 22:02pm.
|
|
|
|
|
But why a shared text file? Is there some particular reason for that? As i see it this would work fine with simply using a TCP/IP connection or UDP or somesuch to send and receive commands, don't know what is available under iOS though. Anyways, if you do insist on the shared file thing then you could try looking into a samba implementation (or there was some kinf of web-based file share protocol, but can't recall the name, webdev or something similar), i have seen software using samba on iOS so that should be possible (maybe there are libraries for it?).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Your best bet should probably be to look up inter-process communications[^] and pick one that fits your situation best. If you have two different systems with two different operating systems, your best bet is to use sockets.
|
|
|
|
|
Dear Developers,
I am using a list control. We are developing a demo version of our product and I want to restrict header click because the items getting sorted.
I have handle HDN_ITEMCLICK event and return at it's very first(if it's a demo version). I have also tried to set *pResult = 1, but both are not working.
Can anyone help me to bring me out.
Thanks.
Amrit Agrawal
|
|
|
|
|
Amrit Agr wrote: ...I want to restrict header click because the items getting sorted.
Can't you just add the LVS_NOSORTHEADER style?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 24-Mar-12 18:28pm.
|
|
|
|
|
But when I have set extended styles of List control, I have not added LVS_NOSORTHEADER style. The code of set extended style is here.
m_lvwTopics.SetExtendedStyle(LVS_EX_ONECLICKACTIVATE|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
Thanks.
|
|
|
|
|
Use Spy++ to see what styles that control has.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I am developing a program with VS2005 which will work on a keyboard only system. And I want to set focus on an activeX(Textbox) when the dialog show up. I use the m_textbox.SetFocus() in the OnTimer() function, but the focus stays on the OK button. And then, using code:
CWnd* pw=GetDlgItem(IDC_TEXTBOX1);
pw is NULL.
When I tried this in the VC++6.0 environment, The focus can be set successfully.
Any suggestion? Thanks.
modified 23-Mar-12 10:21am.
|
|
|
|
|
|
With each passing day, I keep feeling like I'm taking 2 steps forward and 1.9 steps backward. I'm not sure what that 0.1 step is telling me, however.
On a dialog, when I right-click a control, I'm wanting to display a list control with images (not bring up a second modal dialog with those images). When an image is selected, or if the list control loses focus, I want it to close. My first go at this was to derive a class from CListCtrl , and display it dynamically. Other variations of this exist on the web, and as a matter of fact I am using some of them elsewhere in my project. The only difference being none of them are derived from CListCtrl . With that in place, the list control displays and I can interact with it. When an item is selected, I get an NM_CLICK notification and can close the list control. The problem is closing the list control when it loses focus, either because I tabbed or mouse-clicked elsewhere. No other messages (e.g., WM_KILLFOCUS , WM_ACTIVATE , WM_LBUTTONUP ) are sent during these events, nor is PreTranslateMessage() called.
My second approach was to instead derive a class from CWnd , with a CListCtrl member variable. The window and the list control displays and I can interact with it (I say "it" because the list control completely covers the window). In addition, message handlers such as OnActivate() , OnKillFocus() , and OnLButtonUp now get called as well as PreTranslateMessage() . When and how these get called depend on how SetCapture() is called.
If I call it in the context of the CWnd object, the message handlers get called. When an item in the list control is selected, OnLButtonUp() is called and I can close the list control. The problem is that it is also called when I click the scroll bar. If I call it in the context of the CListCtrl object, some of the message handlers and PreTranslateMessage() get called. Now when an item in the list control is selected, PreTranslateMessage() is called with WM_LBUTTONDOWN and I can close the list control. The problem is that it is also called when I click the scroll bar. Both of these approaches require a little bit of client-to-screen and point-in-rect fiddling, but I *think* it's possible.
At this point, I'm confused as to exactly what I have. Neither approach gets me exactly what I'm after, and I feel like I'm having to put too much code in it to do what is otherwise easy when dealing with a CListCtrl object on a dialog template. I'd much prefer the first approach as it seems a bit cleaner, but I'm not against the second approach if I didn't feel like the "hidden" window was getting in the way.
Having said all of that, am I completely doing something wrong, or just mising some little piece that would sew it all up nicely?
Thanks.
- DC
[edit]
I made a bit of progress today by subclassng both CWnd and CListCtrl (before I was just using a native CListCtrl object). Now I'm able to intercept various messages in the list control class. The list control is opening and closing as expected. So far so good...
[/edit]
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
modified 23-Mar-12 12:03pm.
|
|
|
|
|
I would use the second approach because it separates handling of the window (loose focus, mouse clicked outside, ESC/TAB pressed) from the list itself.
If clicking the scroll bar is your only problem, the solution is simple:
If the point is inside the client rect of the list control, you clicked the list, otherwise you clicked the scroll bar when inside the list controls window rect (the parent window client rect when using the second approach).
|
|
|
|
|
Jochen Arndt wrote: If clicking the scroll bar is your only problem, the solution is simple: If the point is inside the client rect of the list control, you clicked the list, otherwise you clicked the scroll bar when inside the list controls window rect (the parent window client rect when using the second approach).
Yeah, I already had that detail worked out. The problem is that a slow, single click on the scroll bar is ignored. If, however, I single click almost to the point of it being a double click, the scroll bar will respond.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Then there is something not OK with the command handling. Did you handle that in the WM_LBUTTONDOWN handler? Because scroll bars act upon button down.
Where did you handle the message (CWNd or list control) and how did you pass it to the scroll bar? For the list control, just call the default handler which will pass the message to the scroll bar.
|
|
|
|
|
Hey Guys,
I ran into a frustrating problem yesterday. I've been using winsock2.h and Afxwin.h to create asynchronous TCP/IP sockets in C++ for awhile (I'm using Visual Studio).
I've also been using Arduinos to deliver sensor data over serial to C++ programs via the Arduino SerialClass (http://arduino.cc/playground/Interfacing/CPPWindows).
I tried combing the two functions yesterday into something that could send serial data over TCP/IP but soon discovered that adding afxwin.h library to my existing serial port reader led to the following error:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
If I remove the windows.h definition from the arduino class I get 81 errors describing things like missing semicolons and undeclared identifiers in the serialclass (the library works fine normally).
I've tried changing the MFC settings in visual studio to work with windows libraries, but I get this error instead:
fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
I've tried #define _AFXDLL, which gives the 'windows.h already included' error again.
Does anyone know a way to make these two headers work with each other so I can integrate the functionality? If not I guess I need to find a way to either
1) Read the serial port without the Arduino SerialClass and windows.h (is that possible?)
2) Broadcast TCP/IP messages without winsock2.h & AFxwin.h
Any help appreciated, I'm rather stuck!
I also can't switch operating system due to the nature of numerous other components in this project.
Thanks,
Ad
|
|
|
|