|
What is the error?
I personally find it better on Oracle to use stored procedures for inserting records.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
I have created an MDI application. In this application, I have a class CMyDoc,which is inherited from CDocument.
Now I want to write some code to open a document of this kind, while not showing the frame and view which are associated with the document.
I write these codes:
{
...
CMyDoc * pDoc=(CMyDoc*)theApp.OpenDocumentFile(m_strNewFileName);
...
}
As you can guess,the frame and view are showed.Please tell me how to open a document without showing the frame and view .
I love sea
|
|
|
|
|
If you didn't open the view, how would the document be shown ? The point of a view is that it's how a document is rendered.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
To Christian,
First thank you very much for your reply!
Yeah,I agree about what you have said. But what i want to do now, is to read
~~~~~
the content of a document.And I donot want that the view and frame are to be
~~~~~~~~~~~~~~~~~~~~~~~~~
showed.
Let us take an example: Suppose that you are going to load the content of a *.txt file. Must you run an notepad.exe? No. You can make it by writing such codes:
CStdioFile f(...);
Do you catch what i mean?
I love sea
|
|
|
|
|
Ah - what is the document ? If it's a custom thing, abstract the loading code into a class, then you can call it from where-ever you like.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi,
I am developing an application to send message to colleagues in our LAN. I hope they receive msgs with their Messenger Service in Win2K.
Now I used ShellExecute("net send...") to send message. And it works. But I don't know how to determine if my application succeeds in sending message.
My second question is, what tcp or udp port does Messenger Service use? Or it uses mailslot?
May I use some APIs to send message to this service directly? I am studying API NetMessageBufferSend(). But I am not sure it is fit for me and how to use it.
Any advice? Thank you.
Dave
|
|
|
|
|
|
I am a novice to Visual C++ and windows programming, and so am attempting to acquire my understanding of it from Charles Petzold's: Programming Windows. No doubt many of you are familiar with it.
I am becoming confused in using the SetDIBitsToDevice function that I am using to display bitmaps, that I have imported as a resource in the executable.
And, so I have several questions about pointers, handles, and casting.
In his book, Petzold describes supplying the necessary parameters, when calling the SetDIBitsToDevive function:
"For the SetDIBitsToDevice and StretchDIBits functions, the information you need includes a pointer to the BITMAPINFO structure of the DIB. As you'll recall, the BITMAPINFO structure comprises the BITMAPINFOHEADER structure and the color table. So, this is simply a pointer to the packed DIB with appropriate casting." Do any of you understand what he is referring to when he says, 'appropriate casting'?
Also, another question: I would like to display the bitmaps by using the FindResource and LoadImage function calls, which both return handles. Is there a way to use handles either as pointers, or by converting them safely to appropriate BITMAPINFO pointers and as pointers to the actual bitmap image bits? Is there a preferred casting operator that be used here?
This is a description of how the author acquires the pointer to the image pixel bits:
"The functions also require a pointer to the pixel bits. This is derivable from information in the information header, although the code is not pretty. Notice that this pointer can be calculated much more easily when you have access to the bfOffBits field of the BITMAPFILEHEADER structure. The bfOffBits field indicates the offset from the beginning of the DIB file to the pixel bits. You could simply add this offset to the BITMAPINFO pointer and then subtract the size of the BITMAPFILEHEADER structure. However, this doesn't help when you get a pointer to a packed DIB from the clipboard, because you don't have a BITMAPFILEHEADER structure."
I imagine a n umber of you folks write programs for image processing, and have an intimate understanding of the mechanics involved here. I would appreciate any information. Thanks.
|
|
|
|
|
hi,
about casting
see to the structure
typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO;
BITMAPINFO is almost same as BITMAPINFOHEADER
casting means
int iVar = 1;
short sVar = (short)iVar; //I cast iVar to sVar
int SetDIBitsToDevice(
HDC hdc, // handle to device context
int XDest, // x-coordinate of upper-left corner of
// dest. rect.
int YDest, // y-coordinate of upper-left corner of
// dest. rect.
DWORD dwWidth, // source rectangle width
DWORD dwHeight, // source rectangle height
int XSrc, // x-coordinate of lower-left corner of
// source rect.
int YSrc, // y-coordinate of lower-left corner of
// source rect.
UINT uStartScan, // first scan line in array
UINT cScanLines, // number of scan lines
CONST VOID *lpvBits, // address of array with DIB bits
CONST BITMAPINFO *lpbmi, // address of structure with bitmap info.
UINT fuColorUse // RGB or palette indexes
);
.h
CBitmap m_bmpLogo1;
CString m_strLogoPath;
HANDLE m_hBitmap;
.cpp
::OnCreate()
CFileFind filefind;
CString strVal = strCurrentPath +"label.bmp";
m_strLogoPath = strVal;
if (filefind.FindFile(strVal))
bLogo = TRUE;
else
m_strLogoPath = "";
if(bLogo)
{
if(!m_bmpLogo1.LoadBitmap(strVal))
{
m_hBitmap = LoadImage (NULL,m_strLogoPath,IMAGE_BITMAP,0,0,
LR_DEFAULTSIZE | LR_LOADFROMFILE ); //| LR_CREATEDIBSECTION
if(!m_bmpLogo1.Attach(m_hBitmap))
m_strLogoPath = "";
}
}
//another function
CBitmap bmp //class
BITMAP Bitmap; //handle
long cx=0,cy=0;
CSize size
bmp.Attach(m_hBitmap);
bmp.GetBitmap(&Bitmap);
size = bmp.GetBitmapDimension();
cx = size.cx; //or Bitmap.bmWidth
cy = size.cy; //or Bitmap.bmHeight
BITMAPINFO info;
ZeroMemory( &info.bmiHeader, sizeof(BITMAPINFOHEADER) );
info.bmiHeader.biWidth = cx; // Set size you need
info.bmiHeader.biHeight = cy; // Set size you need
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 24; // Can be 8, 16, 32 bpp or other number
info.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
//..
//I never used SetDIBitsToDevice() so i give you another example function
//Let's create a new bitmap
HDC dc= CreateCompatibleDC(NULL);
VOID *pvBits;
HBITMAP oldBmp;
m_hNewbmp = CreateDIBSection( dc, &info, DIB_RGB_COLORS, &pvBits,NULL, 0);
oldBmp = (HBITMAP)SelectObject(dc,m_hNewbmp);
//..
delete dc;
hope it helps a bit,
dan
|
|
|
|
|
Hello everyone!! Ok I got the bool loop done....now my only question is how do I get my program to repeat until 'E' is entered....I don't know if I'm supposed to put the void functions in the other.....PLease Help.....
#include <iomanip>
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
void PrintInstructions (float&, string&, float&);
void GetSingleTransInfo(char&, float&);
void ProcessDeposit (float, float, float&);
void ProcessCheck (float, float, float&, float&);
void PrintFinalTotals ();
void PrintBlankLines (int);
const float CHECK_CHARGE = .15f;
const float DEPOSIT_CHARGE = .10f;
const float ONE_TIME_CHARGE = 5.00f;
int main ()
{
string month;
float balance;
float transAmount;
char transCode;
float charge;
float currentBalance;
PrintInstructions (balance, month, charge);
GetSingleTransInfo (transCode, transAmount);
if (transCode == 'C')
{ ProcessCheck(transAmount, balance, currentBalance, charge);
}
if (transCode == 'D')
ProcessDeposit(transAmount, balance, currentBalance);
else
cout <<" This is the end of the month\n";
return 0;
}
void PrintInstructions(/*out*/ float& beginBalance, /*out*/ string& month, /*out*/ float& charge)
cout << "Please enter the month to be balanced: ";
cin >> month;
cout << endl;
cout << "Please enter the beginning balance for the month: ";
cin >> beginBalance;
below500 = (beginBalance < 500.00);
if (below500)
{
charge = ONE_TIME_CHARGE;
}
PrintBlankLines (3);
system ("pause");
system ("cls");
void GetSingleTransInfo (/*out*/ char& code, /*out*/ float& amount)
PrintBlankLines (4);
cout << " Select form the following transactions:\n\n";
cout << " C / c - for a check\n";
cout << " D / d - for a deposit\n";
cout << " E / e - for end of the month\n\n";
PrintBlankLines (3);
cout << "Enter you transaction choice: ";
cin >> code;
code = toupper (code);
cout << endl;
while (code != 'C' && code != 'D' && code != 'E')
{
cout << "\nError.....you must select a code from above\n\n";
cout << "Please enter a new transaction code: ";
cin >> code;
cout << endl;
code = toupper (code);
}
if (code == 'C' )
{
cout << "Please enter transaction amount: ";
cin >> amount;
cout << endl;
}
if (code == 'D')
{
cout << "Please enter transaction amount: ";
cin >> amount;
cout << endl;
}
system ("pause");
system ("cls");
}
//***************************************************************************************************************
void ProcessCheck(/*in*/ float amount, /*in*/ float balance,
/*out*/ float& currBalance, /*out*/ float& charge)
// Purpose: Deduct amount of check from balance....apply charges if balance falls below zero by
// cause of check. Apply charge if balance falls below $500.00.
// Pre:
// Post:
{
bool below500;
currBalance = balance - amount;
below500 = (currBalance < 500.00);
cout << " Check Transaction\n\n\n";
cout << fixed << setprecision (2) << endl;
cout << "Check Amount: " << amount << endl;
cout << "Current Balance: " << currBalance << endl;
cout << "Check Charge: " << CHECK_CHARGE << endl;
if (below500)
{
charge = ONE_TIME_CHARGE;
cout << "One Time Below $500.00 charge: " << charge << endl;
}
GetSingleTransInfo (transCode, transAmount);
system ("pause");
system ("cls");
}
//***************************************************************************************************************
void ProcessDeposit (/*in*/ float amount, /*in*/ float balance,
/*out*/ float& currBalance)
{
currBalance = balance + amount;
cout << " Deposit Transaction\n\n\n";
cout << fixed << setprecision (2) << endl;
cout << "Deposit Amount: " << amount << endl;
cout << "Current Balance: " << currBalance << endl;
cout << "Deposit Charge: " << DEPOSIT_CHARGE << endl;
}
Thanks in advance!!
Autumn
|
|
|
|
|
while((_getch()!="e") || (_getch()!="E"))
{
blah blah blah;
}
would be the easiest way of getting it to run until E is pressed.
|
|
|
|
|
That's helps alot Carrie....I jus don't know where to put it....if I put it in the main....it get a never ending loop!!! Thanks
Autumn
|
|
|
|
|
shouldn't that be && ? _getch() will always != 'e' || != 'E'.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
now Christian...dont' go off confusing me tonight!!! I hope your Thansgiving was well.... So how/ where in my program is this loop supoosed to be. It will run through once but that is all... Do I need to move things around? I'm lost please help!!
Autumn
|
|
|
|
|
Place the loop around all of your code that you want to repeat.
Also change the loop from above to this.
char ch = _getch();
while (ch != 'e' && ch != 'E')
{
...
}
because the way it is written above it will call getch two separate times and remove two separate characters.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
/me hangs her head
Yeah, you're right. It was made after midnight though so I think I'm excempt from the public flogging
|
|
|
|
|
Well, I can only think of one person who was perfect, and look what they did to Him....
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Hi,
We have a problem with corrupted addresses when sending a pointer in the LPARAM argument of ::SendMessage() to another application.
Roughly, the code looks like this:
TCHAR g_szName[] = _T("abcd");
VOID SendName(HWND hWnd)
{
::SendMessage(hWnd, WM_USER, 0, (LPARAM)g_szName);
}
In the debugger, we can have g_szName equal to for instance 0x0e006719 before the ::SendMessage() call. But in the receiving application the higher bits are cleared so we only have 0x00006719 there, which isn't likely to contain the string we want to use...
Any idea why this is? I can assure you it's annoying and it feels like I've done exactly this successfully at least a thousand times before, not to mention WM_SETTEXT , which is practically the same, only it works...
I appreciate any pointers on this subject.
Thanks!
/Johann Gerell
|
|
|
|
|
Pointers do not generally marshall across process boundaries.
You will need to allocate memory using the GlobalAlloc function in order to pass the data between your two applications.
WM_SETTEXT has some special processing in it to marshall your pointers for you. I think the same goes with WM_GETTEXT and possibly a few other messages.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Paul Watt wrote:
You will need to allocate memory using the GlobalAlloc function in order to pass the data between your two applications.
I can't with pride use a function documented as being there to provide compatibility for 16 bits apps. And, are you really sure it does what it promises? Since Win32 doesn't have separate local and global heaps (only local, right?), how could that function allocate global heap?
Pointers do not generally marshall across process boundaries.
Yes, of course - I know that. Normally. But last night/morning at 5.30 AM, after long hours preparing for a first press demo of our product some hours later, neither me or my co-worker accepted this reason (happens way too often).
I told him (with an enlightened smile) "...but each process has its own address space and pointers from one doesn't translate to the other." Upon which he (of course) replied "Of course." But did we accept that? No. At that hour without any sleep, things should just work...
We already use WM_COPYDATA for IPC and that's the way to here also, but this morning I could have sworn there were no such thing as WM_COPYDATA...
Thanks anyway!
/Johann Gerell
|
|
|
|
|
I love reason messages like this. Every programmer worth his weight in salt has done stuff like this. It brings back so many "happy" memories.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Paul Watt wrote:
You will need to allocate memory using the GlobalAlloc function in order to pass the data between your two applications.
That is incorrect. The local/global distinction is a holdover from Win16. From MSDN:Memory objects allocated by GlobalAlloc and LocalAlloc are in private, committed pages with read/write access that cannot be accessed by other processes. Memory allocated by using GlobalAlloc with GMEM_DDESHARE is not actually shared globally as it is in 16-bit Windows. This value has no effect and is available only for compatibility. Applications requiring shared memory for other purposes must use file-mapping objects. I wish it were still as easy as calling GlobalAlloc.
--Mike--
Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Use WM_COPYDATA to send data between applications.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Definately. That's what we've been doing and should without question continue to do. Early morning hours can do much damage to ones brain.
Thanks for the input!
/Johann Gerell
|
|
|
|
|
Johann Gerell wrote:
Early morning hours can do much damage to ones brain.
I couldn't agree more. Happens to me at least 5 times a day!
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|