|
ThatsAlok wrote:
"it require MIND to MIND"
I thought 'mind' comes as default and free with every package. Is it removed nowadays coz of complaints from 3rd party mind builders ?
suhredayan There is no spoon.
|
|
|
|
|
suhredayan® wrote:
Is it removed nowadays coz of complaints from 3rd party mind builders ?
Yes, testing Deptt Complaint about this! and programmer removed that :->
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
unidentify wrote:
onkeydown(UINT nChar, ...)
{
char lschar = char(nChar);
if (lschar=='A') AfxMessageBox("Key A is pressed");
}
change this to
onkeydown(UINT nChar, ...)
{
char lschar = char(nChar);
if (lschar==VK_UP) AfxMessageBox("Key UP is pressed");
}
for rest you can make yourself here is Virtual keycode for them VK_RIGHT VK_DOWN VK_LEFT VK_ADD VK_SUBTRACT
cheers,
Alok Gupta
|
|
|
|
|
I'm writing a file parser. It's really pretty simple. Here's a sample file:
B C 25
A D 36
D E 63
B A 48
C D 30
D B 52
E C 30
C P 30
P Q 52
Q X 51
X Z 70
Z X 20
X Q 20
*
My question is this: Notice that blank line in the middle? How, in C++ using ifstream, can I detect when the parser reaches a blank line such as that one, but still be able to continue parsing?
Thanks for any help!
|
|
|
|
|
There is Function for detecting EOF() using that you can read your file upto last end of file!.
Now for detecting and ignoring Blankline, read file line by line (yeah ifstream has function to do so)and then you can check for empty line easily by using strcmp().
[Vote One Here, Complete my Survey....]
Alok Gupta visit me at http://www.thisisalok.tk
"I Think Believe this Will Help"
|
|
|
|
|
Hi,
This line is not a blank line.
The legnth of that line is 1 and it's containing '\n'(0x0d).
Regards,
Eli
|
|
|
|
|
Thanks. That helped some, but I'm still not sure how to do it. I'm fairly experienced with C++, I've just literally haven't ever used standard file input and output interface, so I'm really pretty stumped. Here's the code for the parser (note this isn't the only code I've written though, I have a lot more that's not the parser):
CompanySetVector CompanySets = CompanySetVector();
ifstream InputFile ("company.in");
ofstream OutputFile("company.out");
string A, B;
float cAB;
int CurrSet = 0;
CompanySets.push_back(new CompanySet);
InputFile >> A;
while (A != "*") {
if (InputFile.peek() == '\n') {
CompanySets.push_back(new CompanySet);
CurrSet++;
}
InputFile >> B;
CompanyDef* pA = CompanySets[CurrSet]->second[A];
CompanyDef* pB = CompanySets[CurrSet]->second[B];
if (pA == NULL) {
CompanySets[CurrSet]->second[A] = new CompanyDef(A);
pA = CompanySets[CurrSet]->second[A];
}
if (pB == NULL) {
CompanySets[CurrSet]->second[B] = new CompanyDef(B);
pB = CompanySets[CurrSet]->second[B];
}
InputFile >> cAB;
ControllingInterest* ci = new ControllingInterest;
ci->first = pB;
ci->second = cAB;
pA->ControllingInterests[B] = ci;
InputFile >> A;
}
Most of that code is pretty project specific an irrelevant to you.
Notice the line:
if (InputFile.peek() == '\n') ...
This is where I need to see if the line is blank. I thought using peek would work, but it doesnt
Do you guys have any other suggestions? Again, thanks for taking time to read this!
|
|
|
|
|
Hi,
Why don't you use FILE instead of ifstream and ofstream?
It's work like this:
FILE *InputFile,*OutputFile;
char InputFileName[] = "company.in";
char OutputFileName[] = "company.out";
char *LineFromFile = new char[100];
CString string;
InputFile = fopen(InputFileNAme,"r");
OutputFile = fopen(OutputFileName,"w");
if(InputFileName == NULL)
{
AfxMessageBox("Unable to open input file");
return;
}
if(OutputFileName == NULL)
{
AfxMessageBox("Unable to open output file");
return;
}
while(fgets(LineFromFile,100,InputFile)!= NULL)
{
string = LineFromFile;
if(string.GetLength() == 1)
{
if(string == '\n')
{
continue;
}
}
else
{
}
}
Good luck,
Eli
|
|
|
|
|
i think that using ifstream and the "<<" operators (forgot what it's called...) will get u what u want.
do something like this:
while (!file.IsEOF()) // read all lines, even if it's blank.
{
__file >> B;
}
if (!B.empty()) // forgot if this works or not. think it should.
__// do the required operation here.
anyway think my code is pretty unclear. here's the explanation.
just keep readin the file, and before performing the push_back operation for the vectors, check that the string is not empty. this will prevent empty string from being written into the vectors. and as the IsEOF() function stops the while loop only on eof, the blank lines will be read.
hope this is correct, as i'm coding off-line here.
|
|
|
|
|
I've tried to look for help here on Codeproject and elsewhere but the only pages I found are ones to automate opening an image and displaying it but I need to do something a little different. I have a valid bitmap image file, however, I also have bitmap data stored elsewhere. Is there a way I can display the bitmap using the data stored elsewhere but use the former valid bitmap images' header and palette data to display with. I tried inspecting some data types to simply display the bitmap but I can't find an obvious way to intercept the loading and simply point a pointer to the new area in memory where the data exists.
I know I could simply write the header to a new file followed by the new data and show that but I'd like to leave less of a footprint behind and streamline the process. Thanks in advance for any help you can give, Nate.
Edit: I guess I never really can find out a good explanation as to what each command does in order to display an image. Too many sites are interested in just telling you how to do it, instead of explaining how to do it; I guess programmers are in that much of a hurry.
|
|
|
|
|
I have an application which uses shared memory, but when I tried to modify this application (which has a different shared memory structure), I keep getting the the old shared memory names.
At run-time if I set a breakpoint an examine the shared memory pointer is has the new data structure. However when I examine the pointer during edit is contains the old memory names.
BUT I cant set data to either the old or new names.
Can I clear out the old names, or am I going mad?!?
I have searched for the old names and they are not present in the project.
grahamfff
|
|
|
|
|
Apparently the Visual Studio 2003 debugger sometimes has trouble keeping up with what's happening in memory. I was trying to do some Interop via C++ Managed Extensions to some legacy code (unmanaged) that allocates an object and returns a pointer to it. While stepping through in the debugger it appears that the data is not returned, when in fact it is. If you build and run the following code, put in a breakpoint where indicated and try to look at what pData points to, it will appear to be undefined, but in fact it is there.
(GetData2() shows it properly, it is effected by what should be a superfluous "new"; if anyone knows that something else is going on, please tell me. Thanks.)
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <time.h>
#pragma unmanaged
class CData
{
public:
int nId;
int nData;
CData()
{
nId = time(0);
nData = 14;
}
};
class DataAccess
{
public:
void ReadData(CData ** data)
{
CData *pUnmanData = new CData();
*data = pUnmanData;
}
};
#pragma managed
using namespace System;
using namespace System::Threading;
using namespace System::Runtime::InteropServices;
[CLSCompliant(true)]
public __gc class Data_Managed
{
public:
int nId_Managed;
void GetData()
{
DataAccess dataAccess;
CData *pData;
//pData = NULL;
dataAccess.ReadData(&pData);
nId_Managed = pData->nId; // Put Break Point Here <<<<<<
}
void GetData2()
{
DataAccess dataAccess;
CData *pData;
pData = new CData();
dataAccess.ReadData(&pData);
nId_Managed = pData->nId;
}
};
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
// TODO: Please replace the sample code below with your own.
Console::WriteLine(S"Hello World");
Data_Managed * data_Managed;
data_Managed = new Data_Managed();
data_Managed->GetData();
Console::Write(S"Id= " );
Console::WriteLine( data_Managed->nId_Managed.ToString() );
data_Managed->GetData2();
Console::Write(S"Id= " );
Console::WriteLine( data_Managed->nId_Managed.ToString() );
return 0;
}
-- Chip Patton
|
|
|
|
|
Hi,
I am writing driver installation program for a system with no mouse.
So I need install the microsoft HID class programatically before doing my installation since my installation requires HID class. Since there in no mouse or any usb devices attached to the system, I have to manually install HID class to load the sys files into system32 folder. I know we can use the func UpdateDriversForPlugandPlay()...I dont how to set the parameters.
Any one have any ideas how to do this..pls help..
Thanks a lot in advance.
|
|
|
|
|
I have a unique project I am trying to accomplish. I have a right-click menu that has several items. This is an existing application so AppendMenu is used for most of the elements. I would like to add one additional elements, called "Select File...", which is actually a popup menu to a submenu. This submenu has to be dynamic to where it reads a directory and lists all the files in that directory. The purpose is to allow a user to select the file he/she chooses and launch an editor.
In researching my project, I have the code to read and list the files. My problem is as follows: how do I capture the menu item that the user selected? In the existing structure, the AppendMenu consists of ID values so in the WM_COMMAND for the window, the ID can be captured. I cannot accomplish my task in the same manner since the # of files can vary. I was planning on using by position but how do I capture the menu item after the user has clicked on it? Maybe I am making this more complicated than it should be???
|
|
|
|
|
You could reserve an id range starting with a known base (eg: IDC_EDIT_FILE_0 ) and use the offset into your file list to compute the popup menu's command id. The handler for menu commands in the range would then compute the index into the file collection and cause the appropriate file to be processed. I'm guessing this is how MFC's MRU support is implemented.
One downside is you can't process file collections outside the range, so you'd need to select a reasonably high upper limit.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
That is kind of how I am presently implemented it. I am reading through the directory, for each value, I am assigning a MenuItemInfo, then doing a SetMenuItemInfo, followed by the InsertMenuItem. I am doing this since I need to be able to retrieve the appropriate filename. I am using BASE_ID_VALUE+nIndex, where nIndex starts at 0 and I keep adding 1 to it. I have attempted to put code in the WM_COMMAND but I can never seem to capture the command to the menu. If I change the code to use AppendMenu, it seems I can capture the message in the WM_COMMAND but I am not sure how to get the filename associated with the menu item clicked. Any ideas on how I can capture the WM_COMMAND message after the user has clicked on one of the filenames?
|
|
|
|
|
Use the ON_COMMAND_RANGE macro to this. You'll need to reserve 2 command ids, one for each end point of the range.
ON_COMMAND_RANGE (CMD_OPEN_FILE_0, CMD_OPEN_FILE_1024, OnOpenFile)
You'll also need to keep the file list around during the execution of the command.
Alternatively, if you're calling TrackPopupMenu() , use the TPM_RETURNCMD flag to retrieve the selected command id. Then, compute the selected filename and just call an api to do your bidding.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Try CCmdUI interface for that menu command. In ClassWizzard you actually have 2 messages for a menu_item: ON_ID_menu_item:COMMAND and ON_ID_menu_item:UPDATE_COMMAND_UI. Use the second one for the purpose you face to.
|
|
|
|
|
Alrightie, we're displaying a stream of html text in our CHTMLView, but we've come up with a "quirk".
The html code we're using contains #links to other spots in the same body of text. When the user clicks the links, the html view displays the following instead of moving the page to the desire spot:
"blank#LINK_NAME"
where link name is the name of our link.
Is there a way to make this work like it does in the browser? My guess is that there's no file name associated with the document, and that's why it doesn't work.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Would it be possible to override CHtmlView::OnBeforeNavigate2() and replace BLANK# present in the url with just # ? I'm hoping this will cause the embedded browser to simply scroll to the link.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I had a similar problem once. Ended up writing my own Async Pluggable Protocol which did the trick. There is an example from Microsoft available there somewhere called db-2-xml which demonstrates this technique.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I have changed the text and background colours of CEdit's in dialog boxes in the past by overriding OnCtlColor. Now I'm trying to do the same thing with a CEdit in a Control Bar. I thought I would be able to override OnCtlColor in CMainFrame but I'm having trouble getting this to work. CMainFrame doesn't seem to receive the WM_CTLCOLOR messsages, although it receives and successfully handles many other messages from the bar .
I attached the dialog bar to the CMainFrame in OnCreate like this:
m_MessagesDlgBar.Create(this, IDD_MESSAGES, CBRS_BOTTOM, IDD_MESSAGES);
Does anyone know where I'm going wrong? Any assistance would be gratefully received.
Best Regards
Cliff Hatch
|
|
|
|
|
VS 2003
I created a dialog bar using the instructions in this article: (minus the InitDialog addition)
http://support.microsoft.com/default.aspx?scid=kb;en-us;185672
then added a WM_CTLCOLOR handler from within the CDialogBar derived class. Worked fine for me.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Thanks Jack.
It works fine for me too
I have some other dialog bars that I will be able to convert usefully in this manner, to reduce the clutter in CMainFrame.
Best Regards
Cliff
|
|
|
|
|
Compiler: VC6 SP5
OS: Windows XP
I have a program that uses CustomDraw on list controls. Everything works until I add a .manifest file to turn on XP styles. When the .manifest file is in place I get the new look fine except on the list controls. On those I frequently get blank lines.
Any suggestions?
|
|
|
|