in these case, i'm using a console aplication, so i don't have the windows class. then how can i call the LRESULT CALLBACK WindowProc() function?
↧
[RESOLVED] how can i call LRESULT CALLBACK WindowProc() function?
↧
using dbms_pipe with C++ to perform daabase operation
using dbms_pipe with C++ to perform database operation
I am getting two result: string and int in c++ code. That I want to store into database. The request which generates result is very frequent. So each time performing db operation to store the result is costly for me.
So how this can be achived using dbms_sql? I dont have any experience and how to start with it. I did google but not clue.
So fo I need to set environment,software or library? I am working in linux.
I could not find any such example on web!
I am getting two result: string and int in c++ code. That I want to store into database. The request which generates result is very frequent. So each time performing db operation to store the result is costly for me.
So how this can be achived using dbms_sql? I dont have any experience and how to start with it. I did google but not clue.
So fo I need to set environment,software or library? I am working in linux.
I could not find any such example on web!
↧
↧
Integration with Word
Hi All.
I', new here are fairly new to C++ so please excuse my ignorance! I'm undertaking a project at the moment which requires me to hook into a custom c++ application from a Java applet via JNI. The c++ application needs to communicate with MS Word and potentially other office programmes in order to highlight text and offer find/replace functionality programatically. The idea is that when the applet is launched, it will communicate with the C++ methods to hook into an open MS Word document and highlight all words that start with the letter 't' for example.
I'm concentrating on the C++ side of things first and i'm just wondering whether anyone can point me in the right direction? Even some basic access to an open word document would give me a great start!
Thanks in advance for your help.
I', new here are fairly new to C++ so please excuse my ignorance! I'm undertaking a project at the moment which requires me to hook into a custom c++ application from a Java applet via JNI. The c++ application needs to communicate with MS Word and potentially other office programmes in order to highlight text and offer find/replace functionality programatically. The idea is that when the applet is launched, it will communicate with the C++ methods to hook into an open MS Word document and highlight all words that start with the letter 't' for example.
I'm concentrating on the C++ side of things first and i'm just wondering whether anyone can point me in the right direction? Even some basic access to an open word document would give me a great start!
Thanks in advance for your help.
↧
Dialog like Window for settings parameters
Hi guys,
I got a main window with menu and the option settings. When I click settings a "dialog" should appear, where the user is able to set some parameters - into a global variable. This window will have something like 12 columns and 8/16/32 (this will vary) rows. This gives us plenty of controls, mostly Edit Controls, which can be filled by the user.
My question is, how to make this window effectively. I was considering dialog box modal/modeless, the problem is the way you have to define a dialog box -> resource file. Defining all the controls in a resource makes the code somehow not very flexible, when I want to change something.
I was trying to make some sort of child window, which is created as follows:
In the WM_CREATE section of the window procedure I call a function, which creates all the buttons, edit boxes etc.
But it's not the child of the main window, which can probably cause trouble in the future (don't know right now). What is good approach to create such "complex" setting windows like in Code::Blocks for example or other pieces of SW? Is it done with dialog boxes through resources? What are the pros and cons of different approaches?
Thank you for advices! :-)
I got a main window with menu and the option settings. When I click settings a "dialog" should appear, where the user is able to set some parameters - into a global variable. This window will have something like 12 columns and 8/16/32 (this will vary) rows. This gives us plenty of controls, mostly Edit Controls, which can be filled by the user.
My question is, how to make this window effectively. I was considering dialog box modal/modeless, the problem is the way you have to define a dialog box -> resource file. Defining all the controls in a resource makes the code somehow not very flexible, when I want to change something.
I was trying to make some sort of child window, which is created as follows:
Code:
HWND GT_CreateWindowMaster(HWND hParent)
{
return CreateWindowEx(
WS_EX_DLGMODALFRAME | WS_EX_TOOLWINDOW, /* Extended possibilites for variation */
GA_WINDOW_MASTER, /* Classname */
"Settings - LIN Master", /* Title Text */
WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_CAPTION | WS_VSCROLL | WS_HSCROLL, /* default window */
0, /* Windows decides the position */
0, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
NULL, /* The window is a child-window to desktop */
NULL, /* No menu */
GetModuleHandle(0), /* Program Instance handler */
NULL /* No Window Creation data */
);
}
Code:
void OnCreate(HWND hParent, int iOffsets[])
{
int i;
for(i = 1; i < NUM_ROWS; i++)
{
CreateIDEdit (hParent, i, 0, iOffsets[0]);
CreateDelayEdit (hParent, i, 1, iOffsets[1]);
CreateLengthCombo (hParent, i, 2, iOffsets[2]);
CreateByteEdit (hParent, i, 3, iOffsets[3]);
}
}
Thank you for advices! :-)
↧
BattleShip Game Help (Urgent)
I'm doing a project and wanted to see if anyone could help me (correct or better yet solve the answer), this is what I got so far.
Code:
/*
Simple Battleship.cpp
*/
#include "stdafx.h"
#include <iostream>
#include <tchar.h>
#include <time.h>
#include <string>
#include <math.h>
using namespace std;
#define MAXSQUARES 9
#define MAXSHIPS 4
#define SPACE ' '
#define MARK 'S'
#define WINNER true
#define LOSER false
class PatternMemory{
private:
PatternMemory *next;
char moves[MAXSHIPS+1];
int readIndex, writeIndex;
int last;
bool moveExists(char move){
for(int i=0;i<MAXSHIPS;i++){
if(moves[i] == move){
return(true);
}
}
return(false);
}
void insertMove(char value, int ptr){
for(int i=MAXSHIPS-1;i > ptr;i--){
moves[i] = moves[i-1];
}
moves[ptr] = value;
}
public:
PatternMemory():next(NULL){
readIndex = MAXSHIPS;
writeIndex = last = 0;
for(int i=0;i<=MAXSHIPS;i++)
moves[i] = MAXSQUARES;
}
void reset(){
readIndex = 0;
}
bool isFull(){
return(writeIndex == MAXSHIPS);
}
bool isEmpty(){
return(writeIndex == 0);
}
void copy(PatternMemory *src, int goodMatches){
for(int i=0;i<goodMatches;i++){
moves[i] = src->moves[i];
}
writeIndex = goodMatches;
readIndex = MAXSHIPS;
}
void put(char value){
if(moveExists(value) || writeIndex >= MAXSHIPS)
return;
if(writeIndex == 0)
moves[writeIndex++] = value;
else{
for(int i=0;i<writeIndex;i++){
if(value < moves[i]){
insertMove(value, i);
writeIndex++;
return;
}
}
moves[writeIndex++] = value;
}
}
int getNextMove(){
int move = moves[readIndex++];
readIndex %= (MAXSHIPS+1);
return(move);
}
PatternMemory *nextPattern(){
return(this->next);
}
bool hasData(){
bool retValue = (readIndex < writeIndex && writeIndex > 0) || isFull();
return(retValue);
}
PatternMemory *link(PatternMemory *n){
next = n;
return(n);
}
void show(){
for(int i=0;i< MAXSHIPS;i++){
cout << (int)moves[i] << " ";
}
cout << endl;
}
};
class Scorer{
private:
/******************QUESTION 6. (6 Points)**********************
1. Declare a floating point variable named points
2. Declare a floating point variable named penalties
*************************************************************/
//Place Code Here
float points;
float penalties;
public:
Scorer(){
reset();
}
/************************QUESTION 7. (6 Points)**********************
Declare a method named reset that does the following:
1. It sets the value of the variable points to zero (0).
2. It sets the value of the variable penalties to zero (0).
3. It does not return a value.
******************************************************************/
//Place Code Here
void reset(){
points = 0;
penalties = 0;
}
float awardPoints(float value){
points += value;
return(points);
}
/************************QUESTION 8. (6 Points)**************************
Declare a method named PenaltyPoints that does the following:
1. It has a single argument named value that is a floating point number.
2. It adds the value of the argument value to the variable penalties.
3. It returns the value of the variable penalties.
**********************************************************************/
//Place Code Here
float PenaltyPoints(float value){
value + penalties;
return (penalties);
}
/************************QUESTION 9. (6 Points)**********************
Declare a method named getTotalPoints that does the following:
1. It has no arguments.
2. It calculates totalPoints by using the following formula:
totalPoints = points - penalties.
3. It returns the floating point value totalPoints.
******************************************************************/
//Place Code Here
getTotalPoints(float totalPoints){
totalPoints = points - penalties;
return (totalPoints);
}
float getPoints(){
return(points);
}
float getPenalties(){
return(penalties);
}
/*************************QUESTION 10. (6 Points)**************************
Declare a method named displayPoints that does the following:
1. It has a single argument named pName that is a string.
2. It outputs a text string to the console that displays names total points.
3. It uses the getTotalPoints() method to get the players total points.
4. It does not return a value.
Example:
If pName has the value The Player and getTotalPoints() returns the value 20, then the following will be displayed:
The Player has 20 points!
************************************************************************/
//Place Code Here
displayPoints(string pName){
cout << pName << "You have " << getTotalPoints() << " Points" << endl;
}
};
class BATTLEBOARD{
private:
/************************QUESTION 11. (6 Points)*************************
1. Declare a character array variable named board whose number of elements is MAXSQUARES.
2. Declare a boolean variable named HitFlag.
**********************************************************************/
//Place Code Here
int board[MAX_SQUARES = 9];
bool HitFlag;
public:
BATTLEBOARD(){}
void PlaceShips(int moves[MAXSHIPS]){
for(int i = 0; i < MAXSHIPS; i++){
board[moves[i]]=MARK;
}
}
/************************QUESTION 12. (6 Points)**************************
Create a method named Reset() that does the following:
1. It has no arguments.
2. It initializes each element of the array variable board to equal the value SPACE.
3. It returns nothing.
************************************************************************/
//Place Code Here
void Reset(string EMPTY = ' '){
MAX_SQUARES = EMPTY;
}
/************************QUESTION 13. (6 Points)**********************
Declare a method named Display that does the following:
1. It has a no arguments.
2. It displays the array board on the console.
3. Specifically, it displays the contents of every cell of the game board on the console.
4. It returns no value.
Example:
| X | | X |
|---|---|---|
| | X | |
|---|---|---|
| X | | |
*********************************************************************/
//Place Code Here
void Display(){
cout << "\n\t" << board[0][0] << " | " << board[0][1] << " | " << board[0][2];
cout << "\n\t" << "---------";
cout << "\n\t" << board[1][0] << " | " << board[1][1] << " | " << board[1][2];
cout << "\n\t" << "---------";
cout << "\n\t" << board[2][0] << " | " << board[2][1] << " | " << board[2][2];
cout << "\n\t";}
/************************QUESTION 14. (6 Points)**********************
Declare a method named checkWinner that does the following:
1. It has no arguments.
2. It counts the number of board cells that do not have the SPACE character in them.
3. It returns true if count equals 0(zero) and returns false if count is not equal to 0(zero).
********************************************************************/
//Place Code Here
virtual bool Fire(int move){
HitFlag = false;
if(board[move] != SPACE){
board[move] = SPACE;
HitFlag = true;
return(checkWinner());
}
return(LOSER);
}
bool getHitFlag(){
return(HitFlag);
}
};
class Player : public Scorer{
protected:
int Locations[MAXSHIPS];
private:
BATTLEBOARD board;
virtual int getShipLocation(){
/************************QUESTION 15. (6 Points)*************************
The method getShipLocation()does the following:
1. It has no arguments.
2. It prompts the Player to "Enter Ship Location: " and then reads the value entered from the keyboard. If the value entered is illegal, prompt the Player to try again to enter a valid value.
3. It returns the location entered by the Player.
***********************************************************************/
//Place Code Here
}
virtual int getMove(){
/************************QUESTION 16. (6 Points)**************************
The method getMove()does the following:
1. It has no arguments.
2. It prompts the Player with "\nYour Move Human: " and then reads the value entered from the keyboard. If the value entered is illegal, prompt the Player to try again to enter a valid value.
3. It returns the move entered by the Player.
************************************************************************/
//Place Code Here
}
public:
Player(){}
void Display(){
board.Display();
}
void askPlayer2PlaceShips(){
int count = 0;
int location;
do{
location = getShipLocation();
Locations[count++] = location;
}while(count < MAXSHIPS);
board.PlaceShips(Locations);
}
void init(){
board.Reset();
}
bool Fire(int move){
return(board.Fire(move));
}
virtual bool launchAttack(Player &opponent){
int move = getMove();
return(opponent.Fire(move));
}
BATTLEBOARD &getBoard(){
return(board);
}
bool ShipWasSunk(){
return(board.getHitFlag());
}
};
class ComputerPlayer: public Player{
private:
int previousMoves[MAXSQUARES+1];
int index; // previousMoves index
PatternMemory *head;
PatternMemory *tail;
PatternMemory *current;
bool lastMoveSankEnemyShip;
bool lastMoveWonGame;
int matches;
/*
* Creates a new pattern memory and links it into to the chain of memories.
*/
void newNode(){
if((lastMoveWonGame && tail == NULL) ||(lastMoveWonGame && tail != NULL && tail->isFull())){
PatternMemory *n = new PatternMemory; // Create a new instance of the patten memory object
if(head == NULL){//Treatment for the first memory pattern
head = tail = n;
}
else{
tail = tail->link(n);//all subsequent patterns link to the tail
}
current = head; //set current to the begining of the chain of memories
if(head != tail)// reset the read memory pointer for all subsequent memories.
current->reset();
}
else{
current = head;
if(tail->isEmpty() == false){// add new memory if tail memory has been written to.
PatternMemory *n = new PatternMemory;
tail = tail->link(n);
}
current->reset();
}
}
bool isMoveDuplicated(int move){
for(int i = 0;i<index;i++){
if(move == previousMoves[i])
return true;
}
return false;
}
// Selects random locations for MAXSHIPS(4) ships
int getShipLocation(){
int location;
bool dupFlag;
do{// make sure locations are unique
dupFlag = false;
location = rand() % MAXSQUARES;
for(int i=0;i<MAXSHIPS;i++){
if(Locations[i] == location){
dupFlag = true;
break;
}
}
}while(dupFlag == true);
return(location);
}
//Get a unique random value for the next move
/************************QUESTION 17. (6 Points)***************************
Create a method named getRandomMove() that does the following:
4. It has no arguments.
5. It generates a random number between 0(zero)
and 8 (MAXSQUARES - 1) for the computerPlayers move.
6. It returns the computerPlayers move.
7. BONUS POINTS(5):
Add code to eliminate duplicate values from the random number generator so that only unique values are returned by the method.
************************************************************************/
//Place Code Here
// get the next move from the current memory
int getPatternMove(){
bool dupMoveFlag;
int move;
do{
move = current->getNextMove();
dupMoveFlag = isMoveDuplicated(move);
}while(dupMoveFlag == true);
if(move == MAXSQUARES)//if we get a 'sentinel' get a randomly generated move.
move = getRandomMove();
return(move);
}
// Get the next move
int getMove(){
int move;
bool dupMoveFlag;
if(current != NULL && ((index == 0 || lastMoveSankEnemyShip || matches >= MAXSHIPS/2) && current->hasData())){
/*
* Perform these actions if this is the first memory
* or the last move sank an enemy ship
* or we've had at least 50% matches with the current memory
* and the current memory has data to be read.
*/
if(lastMoveSankEnemyShip == false && matches >= MAXSHIPS/2 && current->isFull()){
if(tail->isEmpty()){
tail->copy(current, matches);
current = tail;
current->reset();
}
}
move = getPatternMove();
}
else if(current->hasData() && lastMoveSankEnemyShip == false){
/*
* Goto the next memory pattern if the last move did not sink an enemy ship
* and there were fewer than 50% matches with the current pattern.
*/
matches = 0;
current = current->nextPattern();
// if data is available, get the move from the pattern
// else get move from random move generator.
if(current != NULL){
if(current->isEmpty() == false){
current->reset();
move = getPatternMove();
}
else
move = getRandomMove();
}
else{
current = head;
move = getRandomMove();
}
}
else{
move = getRandomMove();
}
previousMoves[index++] = move;// store current move in previous moves data store
cout << "\nMy Move Is: " << move << endl;
return(move);
}
public:
ComputerPlayer():head(NULL), tail(NULL){
srand((unsigned int)time(0));
}
void init(){
Player::init();
for(int i=0;i<=MAXSQUARES;i++){
previousMoves[i]=MAXSQUARES;
}
index = 0;
matches = 0;
newNode();
lastMoveSankEnemyShip=false;
lastMoveWonGame=true;
}
bool launchAttack(Player &opponent){
bool status = Player::launchAttack(opponent);
lastMoveSankEnemyShip=false;
if(opponent.ShipWasSunk() && current != NULL){
current->put(previousMoves[index - 1]);//memorize last move in pattern memory
lastMoveSankEnemyShip=true;
matches++;
}
lastMoveWonGame = status;
return(status);
}
void showMemory(){
PatternMemory *p = head;
while(p != NULL){
p->show();
p = p->nextPattern();
}
}
};
class BATTLESHIP{
private:
/************************QUESTION 18. (6 Points)***************************
1. Declare a variable named human that is an instance of the Player class.
2. Declare a variable named computer that is an instance of the ComputerPlayer class.
************************************************************************/
//Place Code Here
int index;
bool gameOver;
enum PLAYER {HUMAN, COMPUTER};
void BSinstructions()
{
cout << "\n\nWelcome to the ultimate man-machine showdown: BattleShip.\n";
cout << "--where human brain is pit against silicon processor\n\n";
cout << "Make your move known by entering a number, 0 - 8. The number\n";
cout << "corresponds to the desired board position, as illustrated:\n\n";
cout << " 0 | 1 | 2\n";
cout << " ---------\n";
cout << " 3 | 4 | 5\n";
cout << " ---------\n";
cout << " 6 | 7 | 8\n\n";
cout << "Prepare yourself, human. The battle is about to begin.\n\n";
}
void initGame(){
human.init();
human.askPlayer2PlaceShips();
computer.init();
computer.askPlayer2PlaceShips();
gameOver = false;
}
public:
BATTLESHIP(){}
void playBattleShip(){
/************************QUESTION 19. (6 Points)***************************
1. Modify this method to ask the player if they want to play again. If the Player answers yes, then play the game again. If the answer is no, then exit the replay loop.
************************************************************************/
//Place Code Here
BSinstructions();
initGame();
human.Display();
//The Game Loop
do{
if(human.launchAttack(computer) == WINNER){
gameOver = true;
cout << "You Sank My Battleship, Human!\n";
cout << "GAME OVER:\n\tYou Won, Human! How Embarrassing!!!\n";
human.awardPoints(20);
human.displayPoints("\tThe Human");
break;
}
else if(computer.ShipWasSunk()== true){
cout << "You Sank My Battleship, Human!\nI'll get you yet!!!\n";
human.awardPoints(5);
computer.PenaltyPoints(5);
}
else{
cout << "You Missed Pitiful Human!\nThe End Is Near!!!\n";
human.PenaltyPoints(2);
}
if(computer.launchAttack(human) == WINNER){
gameOver = true;
human.Display();
cout << "I Sank Your Battleship, Human!\n";
cout << "GAME OVER:\n\tI Won, Human! You Are No Match For My Superior Intelligence!!!\n";
computer.awardPoints(20);
computer.displayPoints("\tThe Computer");
break;
}
else if(human.ShipWasSunk() == true){
cout << "I Sank Your Battleship, Human!\nYou Are Doomed!!!\n";
human.PenaltyPoints(5);
computer.awardPoints(5);
}
else{
cout << "I Missed You This Time, Pitiful Human!\nEnjoy It While You Can!!!\n";
computer.PenaltyPoints(2);
}
human.Display();
//computer.Display();
}while(gameOver == false);
//Place Code Here: play again loop
//The code below is run after the player indicates they do
//not wish to continue playing.
cout << endl << endl;
/*************************************************************************
BONUS POINTS(20):
Add code to print out congratulatory and game status messages to the Player.
1. The series winner is determined by who has the most points. Use human.getTotalPoints() to get the human players points and computer.getTotalPoints()to get the computer players points. If the human has more points than the computer, then the human has won the series.
2. Use a conditional statement to determine who the series winner is and display the appropriate messages.
3. If both players have equal scores, then declare a tie and display an appropriate message.
************************************************************************/
//Place Code Here
cout << "\nThanks For Playing BattleShip\n";
}
};
int _tmain(int argc, _TCHAR* argv[])
{
/************************QUESTION 20. (6 Points)********************
1. Declare a variable that is an instance of the BATTLESHIP class.
2. Use the instance variable from step 1 above to activate the playBattleShip method to run the game.
*****************************************************************/
//Place Code Here
return 0;
}
↧
↧
CRM Program Sales
Hi
I want to create crm program for sales and watch my customer. Did anyone make something in C++ so i can take some ideas;
I want to create crm program for sales and watch my customer. Did anyone make something in C++ so i can take some ideas;
↧
Access field problem with C++Builder Code
Hi
I have create a simple program with database in access.But i have a problem.
I have a field that i put numbers like that 18-03-0000969-000-00. So when the user try to insert a number like that on database i have a problem. My code for that field is this:
ADOTable1->FieldValues["AR_PAROXHSD"]= Edit2->Text ;
and the field on access is "text ", size:255, required:yes,
So when the user insert a new record and a number like 18-03-0000969-000-00 on database insert a number only 14 or 15 and i dont know why. can anyone help;
I have create a simple program with database in access.But i have a problem.
I have a field that i put numbers like that 18-03-0000969-000-00. So when the user try to insert a number like that on database i have a problem. My code for that field is this:
ADOTable1->FieldValues["AR_PAROXHSD"]= Edit2->Text ;
and the field on access is "text ", size:255, required:yes,
So when the user insert a new record and a number like 18-03-0000969-000-00 on database insert a number only 14 or 15 and i dont know why. can anyone help;
↧
WM_NCHITTEST and WM_NCCALCSIZE on Awesomium UI
Hello. I'm currently working on a custom interface utilizing the Awesomium library (Chromium rendering engine for use of HTML, CSS and Javascript for UI). I've read through the tutorial on how to "extend" the windows frame into the client area to hide it behind what is drawn in the client area (http://msdn.microsoft.com/en-us/libr...v=vs.85).aspx). I have successfully accomplished this task, but NCA hit-testing that is supposed to be happen by using the DwmDefWindowProc or the custom hit-test method does not occur. When I first launch the WM_NCHITTEST and WM_NCCALCSIZE messages are dispatched, but never again after the awesomium window area covers the frame. Thus it seems like the mouse cannot be captured in these areas (borders and caption).
So the gist of it is: I need to retain the move/resize/snap-to-size functionality of the windows frame while it is hidden.
Here is the code I have so far:
Any help with this would be greatly appreciated!
Thank you, and best regards,
Oyvind
So the gist of it is: I need to retain the move/resize/snap-to-size functionality of the windows frame while it is hidden.
Here is the code I have so far:
Code:
#include "view.h"
#include <Awesomium/WebCore.h>
#include <Awesomium/STLHelpers.h>
#include <Uxtheme.h>
#include <dwmapi.h>
#include <gdiplus.h>
#include <vector>
#include <iostream>
class ViewWin;
static bool g_is_initialized = false;
static std::vector<ViewWin*> g_active_views_;
const wchar_t szWindowClass[] = L"ViewWinClass";
const wchar_t szTitle[] = L"Application";
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
using namespace Awesomium;
/*
* MACROS
*/
#define RECTWIDTH(rc) (rc.right - rc.left)
#define RECTHEIGHT(rc) (rc.bottom - rc.top)
#define LEFTEXTENDWIDTH 8
#define RIGHTEXTENDWIDTH 8
#define BOTTOMEXTENDWIDTH 20
#define TOPEXTENDWIDTH 33
#define TOPEXTENDWIDTH_ZOOM 33
#define BIT_COUNT 32
#ifndef GET_X_LPARAM
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
#endif
#ifndef GET_Y_LPARAM
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif
#define TMT_CAPTIONFONT 1
class ViewWin : public View, public WebViewListener::View
{
public:
ViewWin(int width, int height)
{
PlatformInit();
web_view_ = WebCore::instance()->CreateWebView(width,
height,
0,
Awesomium::kWebViewType_Window);
web_view_->set_view_listener(this);
// Create our WinAPI Window
HINSTANCE hInstance = GetModuleHandle(0);
hwnd_ = CreateWindow(szWindowClass,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
width,
height,
NULL,
NULL,
hInstance,
NULL);
if (!hwnd_)
exit(-1);
web_view_->set_parent_window(hwnd_);
ShowWindow(hwnd_, SW_SHOWNORMAL);
UpdateWindow(hwnd_);
SetTimer (hwnd_, 0, 15, NULL );
g_active_views_.push_back(this);
}
virtual ~ViewWin() {
for (std::vector<ViewWin*>::iterator i = g_active_views_.begin();
i != g_active_views_.end(); i++) {
if (*i == this) {
g_active_views_.erase(i);
break;
}
}
web_view_->Destroy();
}
HWND hwnd() { return hwnd_; }
static void PlatformInit() {
if (g_is_initialized)
return;
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(0);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = szWindowClass;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc)) {
exit(-1);
}
g_is_initialized = true;
}
static ViewWin* GetFromHandle(HWND handle) {
for (std::vector<ViewWin*>::iterator i = g_active_views_.begin();
i != g_active_views_.end(); i++) {
if ((*i)->hwnd() == handle) {
return *i;
}
}
return NULL;
}
// Following methods are inherited from WebViewListener::View
virtual void OnChangeTitle(Awesomium::WebView* caller, const Awesomium::WebString& title)
{
std::string title_utf8(ToString(title));
std::wstring title_wide(title_utf8.begin(), title_utf8.end());
SetWindowText(hwnd_, title_wide.c_str());
}
virtual void OnChangeAddressBar(Awesomium::WebView* caller, const Awesomium::WebURL& url) { }
virtual void OnChangeTooltip(Awesomium::WebView* caller, const Awesomium::WebString& tooltip) { }
virtual void OnChangeTargetURL(Awesomium::WebView* caller, const Awesomium::WebURL& url) { }
virtual void OnChangeCursor(Awesomium::WebView* caller, Awesomium::Cursor cursor) { }
virtual void OnChangeFocus(Awesomium::WebView* caller, Awesomium::FocusedElementType focused_type) { }
virtual void OnShowCreatedWebView(Awesomium::WebView* caller, Awesomium::WebView* new_view, const Awesomium::WebURL& opener_url, const Awesomium::WebURL& target_url, const Awesomium::Rect& initial_pos, bool is_popup) { }
virtual void OnAddConsoleMessage(Awesomium::WebView* caller, const Awesomium::WebString& message, int line_number, const Awesomium::WebString& source) { }
protected:
HWND hwnd_;
};
/**---------------------------------
* WndProc
-----------------------------------*/
// Paint the title on the custom frame.
void PaintCustomCaption(HWND hWnd, HDC hdc)
{
RECT rcClient;
GetClientRect(hWnd, &rcClient);
HTHEME hTheme = OpenThemeData(NULL, L"CompositedWindow::Window");
if (hTheme)
{
HDC hdcPaint = CreateCompatibleDC(hdc);
if (hdcPaint)
{
int cx = RECTWIDTH(rcClient);
int cy = RECTHEIGHT(rcClient);
// Define the BITMAPINFO structure used to draw text.
// Note that biHeight is negative. This is done because
// DrawThemeTextEx() needs the bitmap to be in top-to-bottom
// order.
BITMAPINFO dib = { 0 };
dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
dib.bmiHeader.biWidth = cx;
dib.bmiHeader.biHeight = -cy;
dib.bmiHeader.biPlanes = 1;
dib.bmiHeader.biBitCount = BIT_COUNT;
dib.bmiHeader.biCompression = BI_RGB;
HBITMAP hbm = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
if (hbm)
{
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcPaint, hbm);
// Setup the theme drawing options.
DTTOPTS DttOpts = {sizeof(DTTOPTS)};
DttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE;
DttOpts.iGlowSize = 15;
// Select a font.
LOGFONT lgFont;
HFONT hFontOld = NULL;
if (SUCCEEDED(GetThemeSysFont(hTheme, TMT_CAPTIONFONT, &lgFont)))
{
HFONT hFont = CreateFontIndirect(&lgFont);
hFontOld = (HFONT) SelectObject(hdcPaint, hFont);
}
// Draw the title.
RECT rcPaint = rcClient;
rcPaint.top += 8;
rcPaint.right -= 125;
rcPaint.left += 8;
rcPaint.bottom = 50;
DrawThemeTextEx(hTheme,
hdcPaint,
0, 0,
szTitle,
-1,
DT_LEFT | DT_WORD_ELLIPSIS,
&rcPaint,
&DttOpts);
// Blit text to the frame.
BitBlt(hdc, 0, 0, cx, cy, hdcPaint, 0, 0, SRCCOPY);
SelectObject(hdcPaint, hbmOld);
if (hFontOld)
{
SelectObject(hdcPaint, hFontOld);
}
DeleteObject(hbm);
}
DeleteDC(hdcPaint);
}
CloseThemeData(hTheme);
}
}
// Hit test the frame for resizing and moving.
LRESULT HitTestNCA(HWND hWnd, WPARAM wParam, LPARAM lParam)
{
// Get the point coordinates for the hit test.
POINT ptMouse = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
// Get the window rectangle.
RECT rcWindow;
GetWindowRect(hWnd, &rcWindow);
std::cout << "Left: " << rcWindow.left << "Top: " << rcWindow.top << "Right: " << rcWindow.right << "Bottom: " << rcWindow.bottom << std::endl;
// Get the frame rectangle, adjusted for the style without a caption.
RECT rcFrame = { 0 };
AdjustWindowRectEx(&rcFrame, WS_OVERLAPPEDWINDOW & ~WS_CAPTION, FALSE, NULL);
// Determine if the hit test is for resizing. Default middle (1,1).
USHORT uRow = 1;
USHORT uCol = 1;
bool fOnResizeBorder = false;
// Determine if the point is at the top or bottom of the window.
if (ptMouse.y >= rcWindow.top && ptMouse.y < rcWindow.top + TOPEXTENDWIDTH)
{
fOnResizeBorder = (ptMouse.y < (rcWindow.top - rcFrame.top));
uRow = 0;
}
else if (ptMouse.y < rcWindow.bottom && ptMouse.y >= rcWindow.bottom - BOTTOMEXTENDWIDTH)
{
uRow = 2;
}
// Determine if the point is at the left or right of the window.
if (ptMouse.x >= rcWindow.left && ptMouse.x < rcWindow.left + LEFTEXTENDWIDTH)
{
uCol = 0; // left side
}
else if (ptMouse.x < rcWindow.right && ptMouse.x >= rcWindow.right - RIGHTEXTENDWIDTH)
{
uCol = 2; // right side
}
// Hit test (HTTOPLEFT, ... HTBOTTOMRIGHT)
LRESULT hitTests[3][3] =
{
{ HTTOPLEFT, fOnResizeBorder ? HTTOP : HTCAPTION, HTTOPRIGHT },
{ HTLEFT, HTNOWHERE, HTRIGHT },
{ HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT },
};
return hitTests[uRow][uCol];
}
LRESULT CustomCaptionProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool* pfCallDWP)
{
LRESULT lRet = 0;
HRESULT hr = S_OK;
bool fCallDWP = true; // Pass on to DefWindowProc?
fCallDWP = !DwmDefWindowProc(hWnd, message, wParam, lParam, &lRet);
// Handle window creation.
if (message == WM_CREATE)
{
RECT rcClient;
GetWindowRect(hWnd, &rcClient);
// Inform application of the frame change.
SetWindowPos(hWnd,
NULL,
rcClient.left, rcClient.top,
RECTWIDTH(rcClient), RECTHEIGHT(rcClient),
SWP_FRAMECHANGED);
fCallDWP = true;
lRet = 0;
}
// Handle window activation.
if (message == WM_ACTIVATE)
{
// Extend the frame into the client area.
MARGINS margins;
margins.cxLeftWidth = LEFTEXTENDWIDTH; // 8
margins.cxRightWidth = RIGHTEXTENDWIDTH; // 8
margins.cyBottomHeight = BOTTOMEXTENDWIDTH; // 20
margins.cyTopHeight = TOPEXTENDWIDTH; // 27
hr = DwmExtendFrameIntoClientArea(hWnd, &margins);
if (!SUCCEEDED(hr))
{
// Handle error.
}
fCallDWP = true;
lRet = 0;
}
if (message == WM_PAINT)
{
PAINTSTRUCT ps;
HDC hdc;
{
hdc = BeginPaint(hWnd, &ps);
PaintCustomCaption(hWnd, hdc);
EndPaint(hWnd, &ps);
}
fCallDWP = true;
lRet = 0;
}
// Handle the non-client size message.
if ((message == WM_NCCALCSIZE) && (wParam == TRUE) )
{
// Calculate new NCCALCSIZE_PARAMS based on custom NCA inset.
NCCALCSIZE_PARAMS *pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
pncsp->rgrc[0].left = pncsp->rgrc[0].left + 0;
pncsp->rgrc[0].top = pncsp->rgrc[0].top + 0;
pncsp->rgrc[0].right = pncsp->rgrc[0].right - 0;
pncsp->rgrc[0].bottom = pncsp->rgrc[0].bottom - 0;
lRet = 0;
// No need to pass the message on to the DefWindowProc.
fCallDWP = false;
}
// Handle hit testing in the NCA if not handled by DwmDefWindowProc.
if ((message == WM_NCHITTEST) && (lRet == 0))
{
lRet = HitTestNCA(hWnd, wParam, lParam);
if (lRet != HTNOWHERE)
{
fCallDWP = false;
}
}
*pfCallDWP = fCallDWP;
return lRet;
}
LRESULT AppWinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
ViewWin* view = ViewWin::GetFromHandle(hWnd);
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
HRESULT hr;
LRESULT result = 0;
switch (message)
{
case WM_CREATE:
{
}
break;
case WM_SIZE:
view->web_view()->Resize(LOWORD(lParam), HIWORD(lParam));
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
{
hdc = BeginPaint(hWnd, &ps);
PaintCustomCaption(hWnd, hdc);
// Add any drawing code here...
EndPaint(hWnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
bool fCallDWP = true;
BOOL fDwmEnabled = FALSE;
LRESULT lRet = 0;
HRESULT hr = S_OK;
// Winproc worker for custom frame issues.
hr = DwmIsCompositionEnabled(&fDwmEnabled);
//std::cout << "Is DWM comp enabled?: " << hr << std::endl;
if (SUCCEEDED(hr))
{
lRet = CustomCaptionProc(hWnd, message, wParam, lParam, &fCallDWP);
}
// Winproc worker for the rest of the application.
if (fCallDWP)
{
lRet = AppWinProc(hWnd, message, wParam, lParam);
}
return lRet;
}
View* View::Create(int width, int height) {
return new ViewWin(width, height);
}
Thank you, and best regards,
Oyvind
↧
Context menu creation
I would like to create a context menu,Its look something like this
my code is
But i am getting Output Like this
What modification i have to do for the desired output
HTML Code:
Delete ->Rung ->Start
->End
->Element
Exit
Code:
case WM_RBUTTONDOWN : //Right click option
{
MENUITEMINFO mi1,mi2={0};
HMENU hPopupMenu = CreatePopupMenu();
HMENU hSubMenu1 = CreatePopupMenu();
HMENU hSubMenu2 = CreatePopupMenu();
InsertMenu(hPopupMenu,0,MF_BYPOSITION|MF_STRING,ID_EDIT_EXTEND,_T("Exit"));
mi1.cbSize=sizeof(MENUITEMINFO);
mi1.fMask=MIIM_SUBMENU|MIIM_STRING|MIIM_ID;
mi1.wID=ID_EDIT_DELETE;
mi1.hSubMenu=hSubMenu1;
mi1.dwTypeData=_T("Delete");
InsertMenu(hSubMenu1,0,MF_BYPOSITION|MF_STRING,ID_DELETE_ELEMENT,_T("Element"));
InsertMenu(hSubMenu1,0,MF_BYPOSITION|MF_STRING,ID_DELETE_RUNG,_T("Rung"));
mi2.cbSize=sizeof(MENUITEMINFO);
mi2.fMask=MIIM_SUBMENU|MIIM_STRING|MIIM_ID;
mi2.wID=ID_DELETE_RUNG;
mi2.hSubMenu=hSubMenu2;
mi2.dwTypeData=_T("Rung");
InsertMenu(hSubMenu2,0,MF_BYPOSITION|MF_STRING,ID_DELETE_START,_T("Start"));
InsertMenu(hSubMenu2,0,MF_BYPOSITION|MF_STRING,ID_DELETE_END,_T("End"));
InsertMenuItem(hSubMenu1,0,false,&mi2);
InsertMenuItem(hPopupMenu,0,false,&mi1);
SetForegroundWindow(hWnd);
GetCursorPos(&ptClient);
TrackPopupMenuEx(hPopupMenu,0,ptClient.x,ptClient.y,hWnd,NULL);
}
HTML Code:
Delete ->Rung
->Element
->Rung ->Start
->End
Exit
↧
↧
Changing screen resolution by program
Hello Experts,
I have made a Win32 GDI Application which runs only in 1024*768 Resolution.
When the application runs on any other resolution, drawings gets disturbed,So i want to restrict the resolution to 1024*768 through program.How to set the resolution to this pixel ,Can i use ChangeDisplaySetting() function to set to a specific pixel?
I have made a Win32 GDI Application which runs only in 1024*768 Resolution.
When the application runs on any other resolution, drawings gets disturbed,So i want to restrict the resolution to 1024*768 through program.How to set the resolution to this pixel ,Can i use ChangeDisplaySetting() function to set to a specific pixel?
↧
[RESOLVED] [Code Blocks] - how add\use TextOut()?
i'm trying use the TextOut() function. but i see 2 problems:
1 - how can i had the libgdi32.a by code?
2 - if i link the library, why i can't see the text?
can anyone advice me?
1 - how can i had the libgdi32.a by code?
2 - if i link the library, why i can't see the text?
Code:
#include <iostream>
#include <string.h>
#include <windows.h>
//#include <WinGdi.h>
using namespace std;
int main()
{
//TextBlink("hello world", 10,20,3,5);
HDC hDC=GetDC(GetConsoleWindow());
SetTextColor(hDC,6);
TextOut(hDC,1,5,"hello world",strlen("hello world"));
cin.get();
}
↧
Cannot automate/simulate listview click of another process (C++/Win32)
I am developing an automation tool. I want to click listview item of another process programatically. I have partially succeeded in doing. But I am getting a slightly different output.I have used NMITEMACTIVATE(I have also used PostMessage Instead of SendMessage in the code below).
Code:
NMITEMACTIVATE nmbh;
nmbh.hdr.code = NM_DBLCLK;
nmbh.hdr.hwndFrom=g_hWnd;
nmbh.hdr.idFrom=GetDlgCtrlID(g_hWnd);
nmbh.iItem=itemval;
nmbh.iSubItem=0;
nmbh.uNewState=0;
nmbh.uOldState=0;
nmbh.uChanged=0;
nmbh.uKeyFlags=0;
SendMessage(GetParent(g_hWnd), WM_NOTIFY,(WPARAM)g_hWnd,(LPARAM)&nmbh);
↧
win32 listbox not populating right
Hi guys,
This is my first posting here, i am trying to learn to program a win32 GUI in code blocks 12.11, but here is the problem,
I have got 2x list boxes on a dialog box window(IDC_LIST1 > Personal Project Notes) and (IDC_LIST2 > Shared Project Notes),see attached pic,
,
The (personal project notes) auto populates on the dialog been created, i can also get the (Shared project notes) to populate from a folder(by clicking button),see attached pic,
,
The problem arises when i click the button(update personal) after clicking the(update shared ), it loads the contents of (shared project notes) into the(personal project notes) list box, even after using the clear button too, this still populates (the personal project notes) when clicking the (update personal)button, see attached pic,
,
please could someone help me resolve this problem, has i have been banging my head against a wall for days now,
This is the code i have been currently experimenting with, please excuse the messy code, as most of it is from examples that i have converted to suit my GUI.
This is my first posting here, i am trying to learn to program a win32 GUI in code blocks 12.11, but here is the problem,
I have got 2x list boxes on a dialog box window(IDC_LIST1 > Personal Project Notes) and (IDC_LIST2 > Shared Project Notes),see attached pic,
The (personal project notes) auto populates on the dialog been created, i can also get the (Shared project notes) to populate from a folder(by clicking button),see attached pic,
The problem arises when i click the button(update personal) after clicking the(update shared ), it loads the contents of (shared project notes) into the(personal project notes) list box, even after using the clear button too, this still populates (the personal project notes) when clicking the (update personal)button, see attached pic,
please could someone help me resolve this problem, has i have been banging my head against a wall for days now,
This is the code i have been currently experimenting with, please excuse the messy code, as most of it is from examples that i have converted to suit my GUI.
Code:
BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){
switch(Message){
case WM_INITDIALOG:
CheckRadioButton(HWND (hwnd),IDRADIO, IDRADIO2, IDRADIO);
{
DlgDirList(HWND (ID_PROJECT_PROJECT_NOTES), pbuffer, IDC_LISTP, 0, DDL_EXCLUSIVE);
HWND hListBox = GetDlgItem(hwnd, IDC_LISTP);
SendMessage(hListBox, LB_DIR, 0, (LPARAM)("*.txt*"));
}
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case ID_UPDATEP:{
SendDlgItemMessage(HWND(hwnd), IDC_LISTP, LB_RESETCONTENT, 0, 0);
DlgDirList(HWND (ID_PROJECT_PROJECT_NOTES), pbuffer, IDC_LISTP, 0, DDL_EXCLUSIVE);
HWND hListBox = GetDlgItem(hwnd, IDC_LISTP);
SendMessage(hListBox, LB_DIR, 0, (LPARAM)("*.txt"));
}
break;
case ID_UPDATES:{
SendDlgItemMessage(HWND(hwnd), IDC_LISTS, LB_RESETCONTENT, 0, 0);
DlgDirList(HWND (ID_PROJECT_PROJECT_NOTES), sbuffer, IDC_LISTS, 0, DDL_EXCLUSIVE);
HWND hList = GetDlgItem(hwnd, IDC_LISTS);
SendMessage(hList, LB_DIR, 0, (LPARAM)("*.txt"));
}
break;
case IDCLEAR:
SendDlgItemMessage(HWND(hwnd), IDC_LISTP, LB_RESETCONTENT, 0, 0);
SendDlgItemMessage(HWND(hwnd), IDC_LISTS, LB_RESETCONTENT, 0, 0);
break;
case IDCREATE:{
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDPAD), NULL, DlgProc);
}
break;
case IDOK:
EndDialog(hwnd, IDOK);
break;
case IDCANCEL:
EndDialog(hwnd, IDCANCEL);
break;
}
break;
case WM_CLOSE:
EndDialog(hwnd, 0);
break;
default:
return FALSE;
}
return TRUE;
}
↧
↧
[RESOLVED] about WriteConsoleOutput() and WriteConsoleOutputAttribute() functions
i understand that i need use WriteConsoleOutputAttribute() for change the colors and WriteConsoleOutput() for write the text. can anyone explain to me how use them?
i have read about them but i don't understand some parameters :(
i have read about them but i don't understand some parameters :(
↧
Win32 child control thread
I created a dialog with a child control, child control has it's own thread and message pump, and it has the dialog window set as the parent.
Is this a bad idea?
I already noticed I cannot wait on the window creation from the main dialog thread, because when the child thread calls CreateWindowEx with my dialog hwnd as the parent, it must invoke the main dialogs message loop, because I get deadlock.
As long as I don't do that, everything seems to work ok.
Do child windows post or send messages to their parents which could potentially cause me more deadlocks? (If I am going to use sendmessage to contact my child control this could cause problems)
Is this a bad idea?
I already noticed I cannot wait on the window creation from the main dialog thread, because when the child thread calls CreateWindowEx with my dialog hwnd as the parent, it must invoke the main dialogs message loop, because I get deadlock.
As long as I don't do that, everything seems to work ok.
Do child windows post or send messages to their parents which could potentially cause me more deadlocks? (If I am going to use sendmessage to contact my child control this could cause problems)
↧
understanding istringstream in c++
Hi,
I am new to c++ and in process fo understading and learning string class.
I am working on istringstream
I get output as 32 40 50 80 902
That is; string has been split up by space.
If I replace space by comma, the output is 32 and all 0 there after.
I cannot understand how it actually works.
PS: Apolologies, if I have posted question in wrong forum. Kindly provide me so not repeat mistake in future.
I am new to c++ and in process fo understading and learning string class.
I am working on istringstream
Code:
std::istringstream iss;
std::string value="32 40 50 80 902";
iss.str (value); //what does this do???
for(int i=0;i<5;i++){
cout<< " " <<i<<"\n";
int val;
iss >> val;
Quote:
I get output as 32 40 50 80 902
Code:
std::string value="32,40,50,80,902";
I cannot understand how it actually works.
PS: Apolologies, if I have posted question in wrong forum. Kindly provide me so not repeat mistake in future.
↧
Item search in Listview control
Hi,In my win32 application i have a list view control with grid view style ,i want to search items/SubItem on this List view control.I used ListView_FindItem macro,But it always returning 0 for both item as well as subitem.How to find out an item or subitem string from a list view control
Code:
UINT uFindReplaceMsg;
BOOL CALLBACK SymbolNCommntDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND HdlgFindOrReplce = NULL; // handle to Find dialog box
switch (message)
{
case WM_INITDIALOG:
{
ListView_SetExtendedListViewStyle(hWndListViewSymbol,LVS_EX_GRIDLINES| LVS_EX_FULLROWSELECT );
}
break;
case WM_NOTIFY:
{
switch(LOWORD(wParam))
{
case IDC_LIST1:
{
switch(((LPNMHDR) lParam)->code)
{
case LVN_KEYDOWN :
{
NMLVKEYDOWN * pnkd = (LPNMLVKEYDOWN) lParam;
//CNTRL+F Find Dialog Box created
if(pnkd->wVKey=='F' || pnkd->wVKey=='f')
{
if(GetKeyState(0x11)<0)
{
static FINDREPLACE Find; // common dialog box structure
static WCHAR szFindWhat[100]; // buffer receiving string
// Initialize FINDREPLACE ZeroMemory(&Find, sizeof(Find));
Find.lStructSize = sizeof(Find);
Find.hwndOwner = hWnd;
Find.lpstrFindWhat = szFindWhat;
Find.wFindWhatLen = _countof(szFindWhat);
Find.Flags =FR_HIDEUPDOWN|FR_HIDEMATCHCASE|FR_HIDEWHOLEWORD ;
HdlgFindOrReplce = FindText(&Find);
}
}
}
break;
default:
{
LPFINDREPLACE lpfr;
if (message == uFindReplaceMsg)
{
if (lpfr->Flags & FR_DIALOGTERM)
{
HdlgFindOrReplce = NULL;
return 0;
}
//If FindNext clicked searcching for the item in list view and make //it selected
if ((lpfr->Flags & FR_FINDNEXT))
{
int i;
LVFINDINFO plvfi={0};
plvfi.flags=LVFI_STRING;
plvfi.psz=lpfr->lpstrFindWhat;
i=ListView_FindItem(hWnd,-1,&plvfi);//returning 0 for any item
DWORD dw=GetLastError();//Returning 0
ListView_SetItemState(hWnd,i,LVIS_FOCUSED|LVIS_SELECTED,0x000F);//For selcting that item
}
else
return DefFrameProc(hWnd, hWndListViewSymbol,message, wParam, lParam);
}
}
}
}
break;
}
}
break;
default:
return FALSE;
}
return TRUE;
}
↧
↧
[RESOLVED] why Mouse Enter\Leave\Hover don't work normaly?
i'm learning more about windows messages:
i see some problems:
- the mouse leave and mouse hover works in same time... why?
- the mouse messages work with client size and not window size, why?(i'm confused here)
Code:
void TrackMouse(HWND hwnd)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(TRACKMOUSEEVENT);
tme.dwFlags = TME_HOVER | TME_LEAVE; //Type of events to track & trigger.
tme.dwHoverTime = 1; //How long the mouse has to be in the window to trigger a hover event.
tme.hwndTrack = hwnd;
TrackMouseEvent(&tme);
}
// Step 4: the Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bool Tracking = false;
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_KEYUP:
if (wParam ==VK_ESCAPE)
DestroyWindow(hwnd);
else
{
char strDataToSend[32];
sprintf(strDataToSend, "%c", wParam);
MessageBox(NULL,strDataToSend, "keyselected",MB_OK);
}
break;
case WM_MOUSEMOVE:
if (!Tracking)
{
TrackMouse(hwnd);
Tracking = true;
SetWindowText(hwnd,"MOUSE Entered");
}
break;
case WM_MOUSEHOVER:
SetWindowText(hwnd,"MOUSE hover");
break;
case WM_MOUSELEAVE:
SetWindowText(hwnd,"MOUSE LEFT");
Tracking = false;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
- the mouse leave and mouse hover works in same time... why?
- the mouse messages work with client size and not window size, why?(i'm confused here)
↧
Working with Log4CXX
I have built LOG4CXX lib and DLL and trying to use it in my application
Loh.h
class Log
{
public:
Log(void);
~Log(void);
void Debug(const char *msg);
private:
static LoggerPtr oLogger;
};
Log.cpp
LoggerPtr oLogger = NULL;
Log::Log()
{
LoggerPtr oLogger(Logger::getLogger("Test"));
PropertyConfigurator::configure("Logger4CXX.properties");
}
void CLogger::Debug(const char *msg)
{
if(CLogger::oLogger != NULL)
{
LOG4CXX_DEBUG(CLogger::oLogger,"Testing application...");
}
}
In my main I am initializing Log class object and calling Debug method to log debug message to a file.
Issue I am facing is at if(CLogger::oLogger != NULL) which is always returning oLogger as NULL.
Can anyone offer any help on this.
Loh.h
class Log
{
public:
Log(void);
~Log(void);
void Debug(const char *msg);
private:
static LoggerPtr oLogger;
};
Log.cpp
LoggerPtr oLogger = NULL;
Log::Log()
{
LoggerPtr oLogger(Logger::getLogger("Test"));
PropertyConfigurator::configure("Logger4CXX.properties");
}
void CLogger::Debug(const char *msg)
{
if(CLogger::oLogger != NULL)
{
LOG4CXX_DEBUG(CLogger::oLogger,"Testing application...");
}
}
In my main I am initializing Log class object and calling Debug method to log debug message to a file.
Issue I am facing is at if(CLogger::oLogger != NULL) which is always returning oLogger as NULL.
Can anyone offer any help on this.
↧
Compiler optimization problem in VS 2008
Hi all,
I am developing a win 32 application on Visual studio2008.In realease mode with compiler optimization disabled ,my application working fine.But,in maximize speed(Compiler optimization field in C++)its not working properly,Iam explaining with a code
While running the application with Compiler optimization disabled Working Fine.In enabled condition(Compiler optimization(Maximize Speed)))always going to else part eventhough i am giving a correct entry.What may be the reason for this problem.Please help me
I am developing a win 32 application on Visual studio2008.In realease mode with compiler optimization disabled ,my application working fine.But,in maximize speed(Compiler optimization field in C++)its not working properly,Iam explaining with a code
Code:
volatile int iExisist=-1;
iExisist=SearchEntry(_T("abc"));//Searching an entry
if(iExiist!=-1)
{
MessageBox(hWnd, _T("Entry Found"), _T("Success"), MB_OK );
}
else
MessageBox(hWnd, _T("Entry not Found"), _T("ERROR"), MB_OK |MB_ICONERROR);
↧