|
Yes, you can cast LPBYTE to LPSTR without really worrying too much.
Rather than use CString, though, I'd probably use either STL algorithms (because LPBYTE and LPSTR can both be treated as STL iterators) or Boost algorithms[^] (which are actually a lot easier to use than the documentation can make it appear), because they will act on your BYTE array, whereas a CString manages its own buffer.
Here's an example of how to find a substring in a BYTE buffer (I've used unsigned char* because I'm testing on OS X, not Windows, so I don't have a BYTE type!):
#include <algorithm>
#include <iostream>
int main()
{
unsigned char buffer[] = { 1, 2, 3, 'H', 'e', 'l', 'l', 'o', 34, 12 };
unsigned char* bufferEnd = buffer + sizeof(buffer);
char lookFor[] = "Hello";
char* lookForEnd = lookFor + strlen(lookFor);
unsigned char* where = std::search(buffer, bufferEnd, (unsigned char*)lookFor, (unsigned char*)lookForEnd);
std::cout << std::distance(buffer, where) << std::endl;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
Any chance, anyone has code to maintain the format:
(###) ###-####
for a CEdit? There are some masked edit controls, but I
cant get them to blend in with what I have. Im just looking
for something small to let me maintain the above phone
format.
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle Brina
|
|
|
|
|
DanYELL wrote: Any chance, anyone has code to maintain the format:
(###) ###-####
for a CEdit? There are some masked edit controls...
Such as this one.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Useless.
Masked Edit conrol is Native With Shell...
|
|
|
|
|
Yeah, but Im looking for just the important
code that would take the contents of a CEdit and
make it stay in the format:
(###) ###-####
I already have a class which makes it hot when I
scroll over it and I dont want to try to combine
that class with another class. Im trying to
keep this simple.
Any chance you have something where if I handle
OnChangeEdit() and I can then call this function
that will maintain that phone number structure?
|
|
|
|
|
DanYELL wrote: I already have a class which makes it hot when I scroll over it...
Makes it hot?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Makes the edit box border glow red. Its very cool.
|
|
|
|
|
Doesn't sound all that involved. Can't you just mix the two together?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
How can I list the users yhat have accounts on an Windows system?
In VC++6, please?
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Have you tried NetUserEnum() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
No. I will. Thanks!
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
It's an old Win32 FAQ (several methods, from Net to COM)
See on Win32 grp;
|
|
|
|
|
I have searched for a while but I couldn't find anything useful. Thanks anyway!
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
RomTibi wrote: I have searched for a while...
Why? That reply was the epitome of useless. The least he could have done was narrow it down.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Don't be so cruel. I'm pleased to receive an answer.
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
If all you require for pleasure is an answer, I could have said, "The weather is warm today." What kilt provided you was about as helpful. Check his post history. He's just consuming space.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
> I have searched for a while but I couldn't find anything useful
There are at least 150 code samples (professional, from MS internal) for 20 years !!!
|
|
|
|
|
I use the vfw library to create an avi file.
1)AviInit
2)AviFileOpen
3)AviFileCreateStream
4)AviStreamSetFormat
5)loop(AviStreamWrite)
Now before I close the avifile i want to change the frame rate. I change the dwRate of AviStreamInfo and then call EditStreamSetInfo. This returns error code:-2147467262.
If I dont call EdiStreamSetInfo and continue with closing the avi file it succeeds.
My question is, if is possible to change the frame rate after writing the stream and before closing the file?
Thank You
|
|
|
|
|
Hi All,
I'm having trouble writing code in C++ to populate an empty TreeView with a directory structure derived from dragging and dropping a folder from Windows Explorer. I'd like the folder being dragged to become the root node of the TreeView and all of its subfolders to become the child nodes. I have ItemDrag, DragEnter, and DragDrop event handlers - it's the DragDrop event handler I'm having problems with. I can't get it to actually populate the TreeView, mainly because I'm not sure how to retrieve the information necessary to copy. Any ideas?
Thanks.
|
|
|
|
|
Is this using Windows Forms (because the event names sound like Windows Forms names...)?
If so, you might have better luck in the Managed C++/CLI forum[^].
However...first, you need to work out which drop format is the one you need to manipulate. You can get that list from the DragEventArgs object that's passed to your event handler:
private: System::Void treeView1_DragOver(System::Object^ sender, System::Windows::Forms::DragEventArgs^ e)
{
array<String^>^ formats2 = e->Data->GetFormats();
}
The Data member of the DragEventArgs class also has another method, GetData, that allows you to retrieve the data associated with any one of those formats. You then need to work out how to decipher and use the data for your format (I see one called "Shell IDList Array", which sounds promising). The documentation will come in handy there, as might this CP article[^], which is written in VB.NET, but probably has the detail you need.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for the reply! I actually managed to get it working using
if(e->Data->GetDataPresent(System::Windows::Forms::DataFormats::FileDrop))
{
array<String^>^ name = (array<String^>^)e->Data->GetData(System::Windows::Forms::DataFormats::FileDrop);
}
in the DragDrop event handler. I used this website (it's C#) to help recursively find child nodes.
And my apologies, I did in fact put this post on the wrong board but thank you for taking the time to assist anyways.
On a side note, would you happen to know how to get the aforementioned functionality by dragging folders onto the application icon? Similar to how you can drag an image file onto a photoshop (or similar program) shortcut, then photoshop opens and displays the image you dragged. Thanks.
|
|
|
|
|
KawiRider wrote: On a side note, would you happen to know how to get the aforementioned functionality by dragging folders onto the application icon? Similar to how you can drag an image file onto a photoshop (or similar program) shortcut, then photoshop opens and displays the image you dragged. Thanks.
Those will get passed into a new instance of your application as command-line parameters - full paths to the folders from my brief testing.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Awesome! This worked perfectly. The first command line argument seems to always be the pathname to the executable. All later arguments match up with the folders I dragged onto the icon. For reference, I used
array<String^>^ cmdLineArgs = System::Environment::GetCommandLineArgs();
inside the Form's load event handler to get the arguments.
Thank you again for your help, saved me some major headaches
|
|
|
|
|
KawiRider wrote: The first command line argument seems to always be the pathname to the executable. All later arguments match up with the folders I dragged onto the icon
Yes, that's right.
I tested using the string array passed into main() - that doesn't include the executable pathname (at least in C++/CLI applications - it is included in the main() argument list in native C++ apps).
KawiRider wrote: Thank you again for your help, saved me some major headaches
My pleasure
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|