|
Hi I want to create a simple windows that displays a message. The message would be passed to it from another application. How is this done. Any guidance would be appreciated. Is this a situation I would use Remote procedure calls. Any help would be most appreciated.
Regards,
A Novice
|
|
|
|
|
Look at WM_COPYDATA in MSDN!
Mh2!
|
|
|
|
|
works great except that the data is passed as a pointer to the structure COPYDATASTRUCT and is cast as LPARAM. One the application recieves this message how I read/reference the pointer to the structure since it is received as the lparam message parameter.
I was thinking something like, but this does not work
COPYDATASTRUCT x;
&x = (COPYDATASTRUCT) lparam;
Any help would be appreciated
Regards,
|
|
|
|
|
Try this;
COPYDATASTRUCT * p;<br />
p = (COPYDATASTRUCT*) lParam;
-Ben
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
I've been trying to do this for quite some time but to no avail. I have a buffer of 8bit integers representing a bitmap image. Since this is an MFC dialog box, I created a picture box, set the style to bitmap, gave it a control variable (m_picture) and the proceeded to do this.
HBITMAP bmap = CreateBitmap(640,480,1,8,copybuffer); //copy buffer is where the image is stored
m_picture.SetBitmap(bmap);
Both of these functions return non-zero/non-null values so I can't image why it is not displaying correctly. If there is another way to display the bitmaps, I'd really appreciate anyone here pointing me in the right direction. Please help me as I've been struggling with this for a long time and I thank everyone ahead of time for the help.
Quadmire
|
|
|
|
|
Hi,
from the programmers' perspective how is a picture newsgroup different from a text based ng? does the same verb commands like ARTICLE,POST etc apply here too?
and to download pics/stuff, is it the same as text based or is there any other protocol for it?
finally point me to a free access picture newsgroup.
TIA.
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
You receive text and binary newsposts in the exactly same way.
All binary stuff, like pictures or files, is encoded with either UUENCODE or Base64, and is really only text. You just get a large textmessage, which you then have to decode, to get the picture or file.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Thanks a lot.
I'm trying to write an app that downloads selected text/banaries from picture newsgroups. So if you have any tricks/tips, gotchas, pl. share them with me.
Incidentally, I noticed your cool MIME decoder class. any more goodies on the topic?
I'm an alien, I'm an alien
it's a beautiful life....
Bush
|
|
|
|
|
Well, you have a tough job in front of you
If the messages is UUENCODED you need to write a decoder. The problem is that there is not a RFC for UUENCODE. The only documentation I have been able to find, is some Free BSD herder files, and some MAN-Pages under Linux.
If the messages is MIME encoded, you should takle a look at RFC2045 - Multipurpose Internet Mail Extensions (MIME) Part One and maybe also RFC2046 - 2048. They define the standard for MIME messages (which are Base64 or Quoted Printable encoded).
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
There are unix based news readers with source. I used one back in college called xrn.
|
|
|
|
|
Is there an easy way to display text ontop of a dialog bar? I have noticed that to simply display the percent complete, the projects shown here on code project do a whole bunch, including adding a seperate class to avoid flickering. It really shouldn't be this hard IMHO...
- John
|
|
|
|
|
I wanted to write a contact manager system but amhaing problems linkint it all up, at the moment I have two main classes -
CPerson - info about a contact
CDatabaseConn - Database functionality
When the user clicks on a button (from within the view) I wanted to know what the best way of getting in all of the contact info into a list in the iew. There are many ways I can see:
1. Overload << in the CPerson class to make the database connection and generate a linked list and pass this back from the view.
2. Instantiate a database connection and then some person objects and get them one by one.
And many other ways I can think of now. I dont know what to have an instance of where.
I hope people can help as Im sure people have these same kind of problems when learning. Also, is there a kind of ystem/approach or tool we can use when doing this...
thanks
|
|
|
|
|
Always I instantite de database clase in the CwinApp class, because this class is easy to access from all others classes.
And I prefer to put in that class all my publics variables, like connection status, user, etc.
Carlos Antollini.
|
|
|
|
|
I have a textbox on the toolbar. Everytime i start the program or go back to the main window, it will be highlight(because there is "ENTER COMMAND HERE" and highlight all these text so that we don't have to delete these string and enter the command). However, sometimes the user can type something, but then do something else, then the textbox will lose focus. If I want to type the command again, i have to use a mouse to highlight the text inside......not very convenient.
Does anyone know how to make it "ALWAYS" highlighted or when the mouse click that textbox, it highlights everything itself. I've tried using message "LBUTTONDOWN" in the view and frame class. It works when i click in the output area, but when i click the tool bar or menu, no highlight.
thanks!!!!
|
|
|
|
|
Does anyone know how to make it "ALWAYS" highlighted or when the mouse click that textbox, it highlights everything itself.
To keep the text highlighted when the control does not have the focus, set the ES_NOHIDESEL style.
When the edit box gets the focus, it sends EN_FOCUS to its parent. You can handle this notification and call SetSel() to select all the text in the control.
--Mike--
http://home.inreach.com/mdunn/
"You named the Borg... Hugh?"
-- Guinan
|
|
|
|
|
Hi,
I have a problem using private temporary tables, from VC.
The Private table is supose to remain throughout the session.
I can create one fine, but i can't access it! If I was to convert my code to use a global temporary table, it works fine.
Anyone offer any advice:
SQLHSTMT hStmt;
SQLAllocHandle(SQL_HANDLE_STMT, m_hDbc, &hStmt);
// Prepare the SQL statement
SQLCHAR szS[] = "create table #test(val integer)";
SQLPrepare(hStmt,szS,strlen((char*)szS));
nResult = SQLExecute(hStmt); <- Work Fine
SQLFreeHandle(SQL_HANDLE_STMT,hStmt);
SQLAllocHandle(SQL_HANDLE_STMT, m_hDbc, &hStmt);
//Ensure That The User Has Not Already Assigned A ReadCode To This Phrase.
SQLCHAR szCheckPresenceSQL[] = "SELECT * FROM #test ";
SQLPrepare(hStmt,szCheckPresenceSQL,strlen((char*)szCheckPresenceSQL));
nResult = SQLExecute(hStmt); //FAILS GET -1
Cheers
Richard
|
|
|
|
|
Your problem is no in VC. Is in SQL Server.
The Temporary tables only exist for the transaction, when you use a temporary table with # this table is droped for the system when you finish the transaction.
In your Application you are usin two transactions, The create if the table and the select from that table.
Is better to use a Stored Procedure, where the table exists only during the execution of the Store, and put de create and select in the store or
you need tu create a global temporary table with ##, this type of table are droped for the system when the user is disconnected.
Do you Understand?
Good Luck
Carlos Antollini.
|
|
|
|
|
I believe SQLEXECUTE Actually creates a stored procedure to cope with the binding of parameters. By using SQLEXECDIRECT the problems solved. And The table is visible through the current session
Richard
|
|
|
|
|
Anyone out there that knows how to get the MX Records for a domain name. Is there any standard win32 functions for that?
I have been looking at gethostbyname(), but it doesn't seem to do what I need, it just get's the IP Address.
I could write all the socket stuff to talk with a DNS Server myself, but if there's allready a way to do it, it would be kinda waste of time...
I have the same problem with Reverse Lookup...
Any ideas?
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I found out my self.
I found windns.h, which only works for win2k, but in the application I work on we only support Win2k or later...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi,
I'm tying to implement some code to restrict the charcters that can be entered into an edit control.
I'm handling the EN_UPDATE message, using CEdit::GetSel to work out where the cursor currently is, checking the charcter prior to the cursor to see if it's allowed. If it isn't, i remove it, and then update the controls contents. When I update the contents, I want to put the cursor back where it was. How?
I tried this:
void CContactDlg::OnUpdateEdit1()
{
// TODO: Add your control notification handler code here
CString m_text;
m_Number1.GetWindowText(m_text.GetBuffer(1024),1024);
m_text.ReleaseBuffer(-1);
int a,b;
m_Number1.GetSel(a,b);
// a is where the cursor is
// i want to place the cursor at (a-1)
m_Number1.SetSel(a-1,a-1,FALSE);
}
This code puts the cursor at the beginning of the line. How can I implement this?
|
|
|
|
|
I beleive you problem is the GetSel is not returning what you think.
Try m_Number1.SetSel(0, m_Number1.LineLenght(-1),TRUE);
Your name implies this is a number only edit box. If that is true have you tried the ES_NUMBER style?
|
|
|
|
|
Ok, this one gets even more wierd now. I'm not using ES_NUMBER because i need to allow a "+" charcter as well (it's for a telephone number in international format).
Tracing through the steps in a debug, the most wierd thing is happening. This is the code for the function that handles the EN_UPDATE message (with line numbers for clarity).
1 CString m_text;
2 m_Number1.GetWindowText(m_text.GetBuffer(1024),1024);
3 m_text.ReleaseBuffer(-1);
4
5 int a,b;
6 m_Number1.GetSel(a,b);
7
8 char new_char;
9 if (m_text.GetLength() > 0) {
10 new_char=m_text.GetAt(a-1);
11 if ( ((new_char < '0') || (new_char > '9')) && (new_char != '+') ) {
12 CString s;
13 s=m_text.Left(a-1);
14 m_Number1.SetWindowText("hello does this work?");
15 m_Number1.SetSel(1,1,FALSE);
16 }
17 }
Ok. Please don't complain about the poor coding style!
Imagine i fill the edit with "1111a", and break at the EN_UPDATE message that entering the "a" character triggered.
m_Number1 is the CEdit bound to the control through classwizard.
lines 1-3 fill m_text with the current text. line 6 fills a with the cursor position.
line 10 puts the charcter to the left of the cursor (the one that was just entered) into new_char.
the if block on line 12 happens if the last character was in invalid one... when i get to line 14, s contains "1111".
This is where the wierdness starts... line 14, when run, does nothing, and the program pointer jumps to line 9. At this point variable a has been set to 0, and therefore i get a debug assertation failure at line 10.
Why on earth is SetWindowText failing to do anything? and why does the program pointer get moved mysteriously?
I can supply the source to the project if it would help.
Please help me!
|
|
|
|
|
You're going about it the wrong way. When the user hits a key, the edit box gets a WM_CHAR message. Handle that message and throw away any characters you don't want to be entered:
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if ( (nChar >= '0' && nChar <= '9') || nChar == '+' || nChar == '\010' )
CEdit::OnChar(nChar, nRepCnt, nFlags);
} ('\010' is backspace)
--Mike--
http://home.inreach.com/mdunn/
"You named the Borg... Hugh?"
-- Guinan
|
|
|
|
|
That is correct.
As you say this edit box is for phone numbers I would consider using a masked edit control and avoiding the mess all together.
|
|
|
|
|